1. What Problem Do Loops Solve?
Don't start with syntax. Start with the problem.
What if a task needs to happen 10 times?
What if it needs to happen 10,000 times?
How can we avoid repeating the same code?
How do we decide when repetition should stop?
Key idea:
A loop allows a program to repeat instructions without writing the same instructions again.
2. Recognising Repetition in a Problem
Before writing code, ask: “What part of this problem is repeating?”
Example 1:
Display the numbers from 1 to 10.
Think:
1. Start at 1.
2. Display the number.
3. Move to the next number.
4. Stop after 10.
Then convert that thinking into Python.
3. for Loops — When You Know What to Iterate Over
Cover/ Example 2:
for number in range(1, 11):
print(number)
Then explain how to think about it, rather than just what each word means.
What is changing?
Where does it start?
Where does it stop?
How many times does the body execute?
, 4. Understanding range()
Break this into/ Example 3:
range(stop)
range(start, stop)
range(start, stop, step)
Include off-by-one errors, because these are important programming-thinking mistakes.
Example 4:
range(1, 10)
does not include 10.
Ask:
“If I need 1–10, what should my stopping value be?”
5. while Loops — When the Ending Point Depends on a Condition
Example 5:
number = 1
while number <= 10:
print(number)
number += 1
Focus on the programmer's reasoning:
Initial state → condition → action → state change → condition again
This is a much better way to understand while loops than memorising syntax.
6. Choosing the Correct Loop
Give yourself decision questions:
Do I have a sequence or known number of repetitions?