Question 1
2 marksState the output when this code runs.
for i = 10 to 0 step -3
print(i)
next iModel answer
10
7
4
1
Explanation
step -3 makes i count down by 3 each pass, starting at 10. The loop continues while i has not gone past the end value 0, so it runs for 10, 7, 4 and 1. The next value would be -2, which is past 0, so the loop stops; 0 itself is never reached because it is not in the sequence.
Mark scheme
-
1 mark
10, 7, 4 (in this order)
Correct output with no working scores both marks. Accept on one line or on separate lines.
-
1 mark
1 is the last value output (and nothing after it: no 0 or -2)
Do not award if 0 or -2 is also output.