Skip to content
Computing · Year 8

Active learning ideas

Iteration: For Loops

Active learning helps students grasp iteration because repeating actions manually first builds concrete understanding before abstract coding. Writing loops on paper or tracing them with peers lets students see the exact number of repetitions, turning a confusing concept into a clear pattern.

National Curriculum Attainment TargetsKS3: Computing - Programming and DevelopmentKS3: Computing - Control Structures
20–35 minPairs → Whole Class4 activities

Activity 01

Problem-Based Learning25 min · Pairs

Pair Programming: Name Processor

Provide pairs with a list of student names. They write a for loop to print personalised greetings, then modify it to count vowels in each name. Pairs test and swap code for peer review.

Design a 'for' loop to process each item in a list of names.

Facilitation TipDuring Pair Programming: Name Processor, assign roles so one student writes the loop while the other tracks iterations on paper to verify the loop ends correctly.

What to look forProvide students with a Python list of fruits, e.g., `fruits = ['apple', 'banana', 'cherry']`. Ask them to write a 'for' loop that prints 'I like [fruit name]' for each item in the list. Collect and check for correct syntax and iteration.

AnalyzeEvaluateCreateDecision-MakingSelf-ManagementRelationship Skills
Generate Complete Lesson

Activity 02

Problem-Based Learning35 min · Small Groups

Small Groups: Nested Pattern Builder

Groups use nested for loops with range() to print multiplication tables or star patterns. Start with a 5x5 grid, then customise sizes. Share screens to compare outputs.

Analyze the efficiency benefits of using a 'for' loop over repeating code manually.

Facilitation TipFor Small Groups: Nested Pattern Builder, provide grid paper or digital drawing tools to help students visualize how inner loops complete for each outer loop iteration.

What to look forDisplay a simple nested 'for' loop on the board, like: `for i in range(2): for j in range(3): print(i, j)`. Ask students to write down the predicted output. Review answers as a class, discussing how the inner loop completes for each outer loop iteration.

AnalyzeEvaluateCreateDecision-MakingSelf-ManagementRelationship Skills
Generate Complete Lesson

Activity 03

Problem-Based Learning30 min · Whole Class

Whole Class: Prediction Relay

Display for loop code snippets on the board. Students predict outputs individually, then relay answers in teams. Run code together to verify and discuss surprises.

Predict the output of a program containing a nested 'for' loop.

Facilitation TipIn Whole Class: Prediction Relay, pause after each prediction to ask students to explain their reasoning, using their hands to count iterations aloud.

What to look forPose this scenario: 'Imagine you have 100 student names and need to email each one a personalized welcome message. Would you write 100 separate print statements, or use a 'for' loop? Explain why your choice is more efficient.'

AnalyzeEvaluateCreateDecision-MakingSelf-ManagementRelationship Skills
Generate Complete Lesson

Activity 04

Problem-Based Learning20 min · Individual

Individual: Loop Debugger

Give buggy for loop code that mishandles lists or ranges. Students fix errors step-by-step, add print statements to trace, and explain changes in a log.

Design a 'for' loop to process each item in a list of names.

Facilitation TipFor Individual: Loop Debugger, give error-filled code with intentional off-by-one mistakes so students practice fixing range() and list indexing.

What to look forProvide students with a Python list of fruits, e.g., `fruits = ['apple', 'banana', 'cherry']`. Ask them to write a 'for' loop that prints 'I like [fruit name]' for each item in the list. Collect and check for correct syntax and iteration.

AnalyzeEvaluateCreateDecision-MakingSelf-ManagementRelationship Skills
Generate Complete Lesson

A few notes on teaching this unit

Teach for loops by starting with physical movement, like stepping in a square or passing notes to each person in a circle, to show finite repetition. Avoid introducing range() before students understand iterating over real data, as this can confuse the purpose of loops. Research shows that tracing loops on paper before coding reduces off-by-one errors and builds confidence in loop structure.

Students will confidently write for loops that iterate over lists and ranges, predict output in nested loops, and explain why loops are more efficient than manual repetition. They will also debug simple loop errors and trace execution step-by-step with peers.


Watch Out for These Misconceptions

  • During Pair Programming: Name Processor, watch for students who assume the loop will run forever due to confusion with while loops.

    Ask partners to count the number of names in the list on paper first, then write the loop to iterate exactly that many times. Have them compare their count to the loop’s output to correct the misconception.

  • During Prediction Relay, watch for students who believe range(5) includes 5.

    Have students write out the sequence 0, 1, 2, 3, 4 on a whiteboard before coding, then test range(5) in the console to confirm. Discuss why computers start counting at 0.

  • During Small Groups: Nested Pattern Builder, watch for students who think nested loops run sequentially, one after the other.

    Ask each group to draw boxes within boxes on paper, labeling how many times the inner loop runs for each outer loop iteration. Use this visual to predict output before coding.


Methods used in this brief