S5 ICT: Python Loops, nested counts and exit conditions
- 2026-11-20
S5 ICT: Python Loops, nested counts and exit conditions
Paper three tests judgement: multiplicative nested counts, sums of squares, halving rounds, sentinel loops, negative steps and grid sizes, plus what break really exits.
Challenge: multiplied counts and exit conditions Nested totals multiply layer by layer, so five by six is thirty and two layers of one hundred give ten thousand. The squares from 1 to 5 total fifty-five and from 1 to 10 total three hundred and eighty-five. Halving one hundred by integer division gives 50, 25, 12, 6, 3 and 1, which is six rounds. A sentinel only signals the end, so 12 and 7 total nineteen. A negative step counts down and the stop is excluded. break exits only its own layer.
01 Paper details (check answers afterwards)
| Item | Detail |
|---|---|
| Questions | 10 |
| Suggested time | 25 |
| Difficulty mix | Foundation 3 · Intermediate 3 · Challenge 3 · Error redo 1 |
| Chapter | Chapter: S5 ICT: Python Loops (for and while) |
| Level | Challenge (10 items) |
02 Questions (10 items)
- FoundationAn outer range(5) wraps an inner range(6). How many times does the inner body run?
- FoundationWith s starting at zero and a loop over range(1, 6) adding i squared, what is s?
- FoundationStarting at n equal to 100, a while n > 1 loop halves n with integer division. How many iterations?
- IntermediateBoth loops in a double loop run 100 times. What is the total number of inner body executions?
- IntermediateSix students each have five subjects, handled by a nested loop. How many iterations?
- IntermediateUsing -1 as the sentinel, the inputs 12, 7 and -1 arrive. How many valid records and what total?
- ChallengeWhat is the sum of the squares from 1 to 10?
- Challengerange(10, 0, -3) yields four values. What is the last one?
- ChallengeAn eight by eight table is filled by a nested loop. How many cells are handled?
- Error redoWhen the inner loop of a nested loop hits break, how many layers are left?
03 Answers and one-line notes
| # | Answer | One-line note |
|---|---|---|
| 1 | Thirty times. | 5 times 6 is 30, so nested counts multiply instead of adding. |
| 2 | 55. | 1 plus 4 plus 9 plus 16 plus 25 is 55. |
| 3 | Six. | The values go 50, 25, 12, 6, 3 and 1, which is six rounds. |
| 4 | Ten thousand. | 100 times 100 is 10 000, so the work grows very fast with each extra layer. |
| 5 | Thirty. | 6 times 5 is 30. |
| 6 | Two records totalling 19. | The -1 only signals the end and is never added. |
| 7 | 385. | Adding 1, 4, 9, 16, 25, 36, 49, 64, 81 and 100 gives 385. |
| 8 | 1. | The values are 10, 7, 4 and 1, with a step of -3 and the stop 0 excluded. |
| 9 | Sixty-four cells. | 8 times 8 is 64. |
| 10 | Only the innermost layer. | break ends just the loop it sits in, so the outer loop continues. |
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.
Want every loop traced line by line? Book a TutorZone tutor and walk through all ten items in 25 minutes.Tutor 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.



