Count-Controlled Loops · بذر 1 · A۴، مناسب چاپ. پاسخ‌نامه در صفحه‌ای جدا برای بزرگ‌ترها چاپ می‌شود.
به انگلیسی

Loops that know when to stop

رایانش · برنامه‌نویسی · سن ۱۴ تا ۱۶ سال
نام ______________________   تاریخ ____________
  1. In a loop over range(5), what does the loop variable hold first?

    • 1
    • 5
    • 0
  2. How many times does a loop over range(5) run?

    • 4
    • 5
    • 6
  3. range(5) hands the loop the numbers 0, 1, 2, 3, 4.

    دور یکی دایره کشیدن:   درست   نادرست

  4. What does range(10, 26, 5) hand the loop?

    • 10, 15, 20, 25, 26
    • 10, 15, 20, 25
    • 26, 25, 20, 15, 10
  5. A loop prints the 7 times table from 0 to 10 with range(11). How many lines print?

    پاسخ: ______________

  6. In the 9 times table loop, what does the loop variable hold on each pass?

    • The next count from 0 to 12
    • Always 9
    • Always 0
  7. How many times does a loop over range(3, 12, 3) run?

    پاسخ: ______________

  8. Sam runs a loop over range(5) expecting 1, 2, 3, 4, 5. What is wrong?

    • It prints nothing
    • The stop is excluded, so it prints 0, 1, 2, 3, 4
    • It prints 1 to 5 twice
LightMySky · lightmysky.comW1-mt_r1eXTWI_6j-s1

پاسخ‌نامه

برای بزرگ‌ترها. تا کردن این صفحه پیش از تحویل بقیه.

Loops that know when to stop W1-mt_r1eXTWI_6j-s1

  1. 0 · Counting starts at 0, so the first value handed over is 0.
  2. 5 · range(5) holds five numbers, so the body runs five times.
  3. درست · A stop of 5 counts up from 0 and stops before 5.
  4. 10, 15, 20, 25 · Start at 10, step by 5, and stop before reaching 26.
  5. 11 · Eleven values means eleven passes and eleven lines.
  6. The next count from 0 to 12 · The variable walks through the range while 9 stays fixed in the body.
  7. 3 · The loop sees 3, 6 and 9, which is three passes.
  8. The stop is excluded, so it prints 0, 1, 2, 3, 4 · The stop value never prints, and counting starts at 0.
کاربرگ · LightMySky