Python: Iteration
On this page9 sections
- 01Lesson objectives
- 02Key vocabulary
- 03Common misconceptions
- 04Teacher activities
- 05Student activities
- 06Practical / learning evidence
- 07Resources and preparation
- 08Assessment for learning
- 09Inclusion and homework
Lesson objectives
By the end of the week, learners should be able to:
- Define iteration and state its benefit for repeated tasks.
- Name the two FOR loop structures in Python.
- Write a FOR loop counting from one to ten.
- Write a WHILE loop with a counter guarding termination.
- Trace both loops predicting the displayed numbers.
Key vocabulary
- Iteration: repeating steps through a loop.
- FOR loop: a loop iterating over an iterable object.
- WHILE loop: a loop repeating while a condition remains true.
- Counter: a variable tracking loop position.
- Guard: the condition preventing a WHILE loop from running forever.
- Sequence: the iterable object a FOR loop traverses.
- Range: the built-in object generating a sequence of numbers.
- Termination: the point a loop stops executing.
- Displayed numbers: the visible output of each iteration.
Common misconceptions
- "FOR loops always count numbers." A FOR loop can iterate over any iterable.
- "WHILE loops never need a guard." Without a guard a WHILE loop runs forever.
- "Two loops cannot count the same range." Two loops can traverse overlapping ranges.
Teacher activities
- Starter: display a repeated counting task and ask which structure suits it.
- Define iteration and name the two FOR loop structures.
- Write a FOR loop counting from one to ten and trace it.
- Write a WHILE loop with a counter guarding termination.
- Compare both loops on efficiency and clarity.
- Close with the both-loops task and exit question.
Student activities
- Answer the starter and state which structure suits repeated counting.
- Define iteration in their own words and state its benefit.
- Write a FOR loop counting from one to ten and display the numbers.
- Write a WHILE loop with a counter guarding termination.
- Display both sequences and compare their efficiency and clarity.
- Answer the exit question in one sentence about WHILE guards.
Practical / learning evidence
A FOR counting loop with displayed numbers, a WHILE counting loop with a guard, and a comparison observation. Submit all three for marking.
Resources and preparation
Computers with the interpreter, blank program windows and sample tracing cards. Prebuild the interpreter in a read-only folder. Disable Caps Lock before typing. Verify the computer starts reliably.
Assessment for learning
Inspect the FOR loop for correct range and displayed numbers one through ten. Check the WHILE loop for a sensible counter guard. Compare both loops for reasonable efficiency and clarity observations. Flag any learner who omits the WHILE guard.
Inclusion and homework
Provide both loops prefilled for the range expressions and allow oral tracing. Allow extra time on the WHILE version. Extend confident learners with two FOR loops and a fourth homework writing a WHILE loop that counts backwards from ten. Homework: write a second FOR loop summing a range and display the total.