S5 ICT: Python Loops, for and while basics
- 2026-11-20
S5 ICT: Python Loops, for and while basics
Paper one builds the foundation: telling for from while, the three forms of range(), counting iterations, initialising an accumulator and indenting the body.
Loop basics: counts, accumulators and indentation A for loop suits a known number of repetitions and a while loop repeats while a condition holds. range(5) gives five values from 0 to 4, range(1, 5) gives four and range(2, 11, 2) gives five adding to thirty. An accumulator must start at zero; 1 to 10 sums to fifty-five and 1 to 100 to five thousand and fifty. The body is indented four spaces and the for line ends with a colon. A while whose condition never fails runs forever.
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 | Basics (10 items) |
02 Questions (10 items)
- FoundationWhat is the main difference between a for loop and a while loop?
- FoundationWhich values does range(5) produce, and how many are there?
- FoundationHow many values does range(1, 5) produce, and what is the last one?
- Intermediaterange(2, 11, 2) produces five values. What is their total?
- IntermediateWith total set to zero and a loop over range(1, 11) adding each i, what is total at the end?
- IntermediateStarting from i equal to 0, a while i < 5 loop adds one to i each round. How many iterations?
- ChallengeWhat happens if the colon is missing at the end of a for line?
- ChallengeWhat does indenting the loop body do?
- ChallengeWhat goes wrong if the accumulator is never set to zero before adding?
- Error redoWhat happens with while True and no break inside the body?
03 Answers and one-line notes
| # | Answer | One-line note |
|---|---|---|
| 1 | A for loop suits a known number of repetitions; a while loop repeats while its condition remains true. | A for loop takes the next value from a sequence; a while loop tests its condition first and stops when it is false. |
| 2 | 0, 1, 2, 3 and 4, five values in total. | range(5) starts at zero and stops before five. |
| 3 | Four values, and the last is 4. | The start 1 is included and the stop 5 is not, so only 1 to 4 appear. |
| 4 | 30. | 2 plus 4 plus 6 plus 8 plus 10 is 30, with a step of 2. |
| 5 | 55. | The numbers 1 to 10 add to 55 because the stop value 11 is excluded. |
| 6 | Five. | i takes the values 0, 1, 2, 3 and 4, and at 5 the condition is false. |
| 7 | A syntax error, and the program will not run. | Python requires compound statements such as for and while to end with a colon. |
| 8 | It marks which statements belong inside the loop. | Only statements at the same indentation level repeat as one block. |
| 9 | A name error, because the variable is not yet defined. | An accumulator must be initialised first, otherwise the very first addition fails. |
| 10 | It becomes an infinite loop and never stops on its own. | The condition never turns false, so the body repeats forever. |
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.



