Skip to content

Iteration: For LoopsActivities & Teaching Strategies

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.

Year 8Computing4 activities20 min35 min

Learning Objectives

  1. 1Design a Python 'for' loop to iterate through a list of strings and print a personalized message for each item.
  2. 2Analyze the efficiency of using a 'for' loop compared to manually repeating code for a given task.
  3. 3Predict the exact output of a program containing nested 'for' loops, including loop bounds and variable changes.
  4. 4Compare the execution flow of a 'for' loop iterating over a list versus a 'for' loop using range().

Want a complete lesson plan with these objectives? Generate a Mission

25 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.

Prepare & details

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

Facilitation Tip: During 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.

Setup: Groups at tables with access to research materials

Materials: Problem scenario document, KWL chart or inquiry framework, Resource library, Solution presentation template

AnalyzeEvaluateCreateDecision-MakingSelf-ManagementRelationship Skills
35 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.

Prepare & details

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

Facilitation Tip: For 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.

Setup: Groups at tables with access to research materials

Materials: Problem scenario document, KWL chart or inquiry framework, Resource library, Solution presentation template

AnalyzeEvaluateCreateDecision-MakingSelf-ManagementRelationship Skills
30 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.

Prepare & details

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

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

Setup: Groups at tables with access to research materials

Materials: Problem scenario document, KWL chart or inquiry framework, Resource library, Solution presentation template

AnalyzeEvaluateCreateDecision-MakingSelf-ManagementRelationship Skills
20 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.

Prepare & details

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

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

Setup: Groups at tables with access to research materials

Materials: Problem scenario document, KWL chart or inquiry framework, Resource library, Solution presentation template

AnalyzeEvaluateCreateDecision-MakingSelf-ManagementRelationship Skills

Teaching This Topic

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.

What to Expect

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.

These activities are a starting point. A full mission is the experience.

  • Complete facilitation script with teacher dialogue
  • Printable student materials, ready for class
  • Differentiation strategies for every learner
Generate a Mission

Watch Out for These Misconceptions

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

What to Teach Instead

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.

Common MisconceptionDuring Prediction Relay, watch for students who believe range(5) includes 5.

What to Teach Instead

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.

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

What to Teach Instead

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.

Assessment Ideas

Exit Ticket

After Pair Programming: Name Processor, collect each pair’s code and ask them to trace their loop on paper, writing the output for each iteration. Review for correct syntax and accurate iteration.

Quick Check

After Small Groups: Nested Pattern Builder, display the nested loop code on the board and ask students to write the predicted output individually. Review answers as a class, discussing how the inner loop completes for each outer loop iteration.

Discussion Prompt

During Whole Class: Prediction Relay, pose this scenario: 'If you wrote a loop to send 250 emails, would you use a for loop or 250 separate print statements? Ask students to explain their choice during the relay to assess understanding of loop efficiency.

Extensions & Scaffolding

  • Challenge students to write a nested loop that prints a multiplication table up to 12x12.
  • Scaffolding: Provide pre-written loop templates with blanks for students to fill in the range values or list names.
  • Deeper exploration: Have students modify a turtle graphics loop to draw increasingly complex shapes, such as spirals or stars.

Key Vocabulary

for loopA control flow statement that allows code to be executed repeatedly. It is often used to iterate over a sequence (like a list, tuple, string) or a range of numbers.
iterationThe repetition of a process or utterance. In programming, it refers to executing a block of code multiple times, typically within a loop.
sequenceAn ordered collection of items, such as a list, string, or tuple, that can be iterated over by a 'for' loop.
range()A built-in Python function that generates a sequence of numbers, commonly used in 'for' loops to repeat actions a specific number of times.
nested loopA loop placed inside another loop. The inner loop completes all its iterations for each single iteration of the outer loop.

Ready to teach Iteration: For Loops?

Generate a full mission with everything you need

Generate a Mission