S5 ICT Programming Loops, Paper 2: steps, conditions and counts
- 2026-11-02
S5 ICT Programming Loops, Paper 2: steps, conditions and counts
Paper 2 covers range(0, 7) printing seven lines, a total of 210 from 1 to 20, five rounds with a step of minus 2 and a while loop adding 3 to reach 21, then seven multiples of 4 up to 30, twenty nested iterations, an even sum of 650, sixteen Collatz steps from 7 and a squares loop ending at 16.
Reminders A range step may be negative, a while loop ends on its condition rather than a limit, and squares are written as i times i.
01 Paper details (check answers afterwards)
| Item | Detail |
|---|---|
| Questions | 10 |
| Suggested time | 25 |
| Difficulty mix | Foundation 4 · Intermediate 3 · Challenge 2 · Error redo 1 |
| Chapter | Chapter: S5 ICT: Programming Loops in Python |
| Level | S5 |
02 Questions (10 items)
- FoundationHow many lines does `for i in range(0, 7): print(i)` print?
- FoundationWith `total = 0` and `for i in range(1, 21): total += i`, what is total at the end?
- FoundationHow many times does `for i in range(10, 0, -2)` iterate?
- Foundation`count = 0` then `while count is less than 20: count += 3`. What is count when the loop ends?
- IntermediateIn `for i in range(1, 31): if i % 4 == 0:`, how many times is the condition true?
- IntermediateIn the nested loops `for i in range(4): for j in range(5):`, how many inner iterations in total?
- Intermediate`s = 0` then `for i in range(1, 51): if i % 2 == 0: s += i`. What is s?
- ChallengeStarting at n = 7, repeat halving when even and 3n + 1 when odd until n = 1. How many steps?
- Challenge`for i in range(1, 5): print(i * i)` prints how many lines, and what is the last one?
- Error redoError repair: a student said `sum(range(5))` is 1 plus 2 plus 3 plus 4 plus 5, giving 15. What is the real total?
03 Answers and one-line notes
| # | Answer | One-line note |
|---|---|---|
| 1 | 7 lines (0 to 6) | range(0, 7) starts at 0 and stops before 7, so it prints 0 to 6, seven numbers in total. |
| 2 | 210 | Summing 1 to 20 gives 210 because range(1, 21) covers exactly the twenty numbers 1 to 20. |
| 3 | 5 times | A step of minus 2 gives 10, 8, 6, 4 and 2; the next value 0 is not above the stop, so there are 5 rounds. |
| 4 | 21 (7 rounds) | Adding 3 each round gives 3, 6, 9, 12, 15, 18 and then 21, where the condition finally fails. |
| 5 | 7 times | The multiples of 4 from 1 to 30 are 4, 8, 12, 16, 20, 24 and 28, seven in all. |
| 6 | 20 | The outer loop runs 4 times and the inner loop 5 times each round, so 4 times 5 gives 20. |
| 7 | 650 | The even numbers from 1 to 50 add to 650, since 25 pairs average 26. |
| 8 | 16 steps | The chain 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1 takes 16 steps. |
| 9 | 4 lines, the last is 16 | The squares of 1 to 4 are 1, 4, 9 and 16, so four lines end with 16. |
| 10 | 10 (0 to 4) | range(5) starts at 0, so the terms are 0, 1, 2, 3 and 4, and the total is 10. |
04 What to do after marking
- After marking, redo only the wrong items and write down which step went wrong (formula, unit, or misread number).
- Repeat the same item two days later; move to the next paper only when both attempts are correct.
- Parents only need the answer and note columns; there is no need to explain every item.
Book an S5 ICT tutorTutor Registration →
Questions and answers are written originally by the TutorZone team and are not taken from any school, publisher or examination authority paper. Every value is checked by computer.


