Four quick questions on Repetition. Answer each one, press Check,
and read why. Your score is at the bottom of the page; press Start
again there and see whether you can get every one right first time.
Questions
What does this program print?
for count in range(3): print(count)
Why
range(3) starts at 0 and stops before 3, so the loop runs three
times, with count set to 0, then 1, then 2.
Which of these loops run exactly five times?
Why
range(1, 6) counts 1 to 5. Counting by twos from 0 gives 0, 2 and 4,
and range(5, 0) is empty: it would need a negative step to count down.
In range(10, 0, step), the step that counts down by twos is .
Answer: -2
How many times does for letter in "loop": run its block?