35 minutes. Instant-marked. Unlimited attempts. Each answer is marked as soon as you choose it, with an explanation. Nothing is saved in this course.
P1. How many times does for i in range(6): run?
Values 0 to 5.
P2. What is the last value of i in range(1, 5)?
Stop is never reached.
P3. A while loop with no update line usually:
It is an infinite loop.
P4. What does while 2 > 5: print("x") print?
The condition is False at the start.
P5. The total of the numbers 1 to 4 is:
1 + 2 + 3 + 4.
P6. A counter that counts even numbers from 1 to 6 ends at:
2, 4 and 6.
P7. For x = 9, while x > 0: x = x - 5 leaves x equal to:
9, then 4, then -1.
P8. Outer range(3) and inner range(2) run the inner body:
3 × 2.