/en-tutor-prep-s5-ict-programming-python-loops-practice-2/
/en-tutor-prep-s5-ict-programming-python-loops-practice-2/
General Inquiry: info@TutorZone.com.hk
Office Hours: Monday to Saturday - 9:00 AM to 6:00 PM
WhatsApp Monday to Sunday - 24 hours
Hotline: +852 6828 1809
Instant Support: +852 9061 3106

S5 ICT: Python Loops, nested loops and accumulators

S5 ICT: Python Loops, nested loops and accumulators

  • 2026-11-20

S5 ICT: Python Loops, nested loops and accumulators

Paper two practises writing: nested iteration counts multiplied, range with a step, factorials, filtering evens and multiples, averages, countdown loops and walking a string.

Nested loops: multiplied counts and filtering A nested loop multiplies the outer and inner rounds, so three times four is twelve. A stepped range takes a start, a stop and a step. A factorial multiplies up from one to reach one hundred and twenty. There are ten evens from 1 to 20 adding to one hundred and ten, and ten multiples of three from 1 to 30. An average is the total divided by the count, so five numbers adding to ninety average eighteen. A countdown by two from ten runs five times.

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 Intermediate (10 items)

02 Questions (10 items)

  1. FoundationIn a nested loop with an outer loop of three rounds and an inner loop of four, how many times does the inner body run?
  2. Foundationrange(1, 7, 2) produces three values. What is their total?
  3. FoundationUse a for loop to work out 1 times 2 times 3 times 4 times 5.
  4. IntermediateHow many even numbers lie between 1 and 20, and what is their total?
  5. IntermediateHow many multiples of 3 are there from 1 to 30?
  6. IntermediateFive inputs 12, 15, 18, 21 and 24 are averaged in a loop. What is the result?
  7. ChallengeStarting at n equal to 10, a while n > 0 loop subtracts 2 each round. How many iterations?
  8. ChallengeHow many times does the body run when a for loop walks the string “loop” character by character?
  9. ChallengeA loop of seven rounds prints two lines each round. How many lines in total?
  10. Error redoWhat is the sum of the digits of the integer 4729?

03 Answers and one-line notes

# Answer One-line note
1 Twelve times. 3 times 4 is 12, because each outer round completes the whole inner loop.
2 9. 1 plus 3 plus 5 is 9.
3 120. The product starts at 1 and is multiplied each round, ending at 120.
4 Ten numbers adding to 110. 20 divided by 2 is 10, and 2 plus 4 up to 20 sums to 110.
5 Ten. They run 3, 6, 9 up to 30, and 30 divided by 3 is 10.
6 18.0. The total is 90 and dividing by 5 gives 18.
7 Five. The body runs for 10, 8, 6, 4 and 2, then n is 0 and the condition fails.
8 Four times. The string has four characters, one iteration each.
9 Fourteen lines. 7 times 2 is 14.
10 22. 4 plus 7 plus 2 plus 9 is 22, which a while loop can do with remainders.

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.

Join as a tutor or coach — academic, music, sports, arts, STEM. Free to register. See how it works →