Skip to content

Iteration: For LoopsActivities & Teaching Strategies

Active learning works for 'for' loops because students need to repeatedly see how sequences drive iteration, and only through doing can they internalize the finite nature of loops. Handling real data in pairs or groups moves theory into practice, turning abstract range() into concrete sums, counts, or patterns students can verify for themselves.

Secondary 3Computing4 activities20 min40 min

Learning Objectives

  1. 1Explain the purpose of a 'for' loop in automating repetitive tasks.
  2. 2Construct a 'for' loop to process each item in a given list or string.
  3. 3Compare the efficiency of using a 'for' loop versus manual repetition for a given task.
  4. 4Analyze the output of a 'for' loop given specific input data.
  5. 5Create a Python program that utilizes a 'for' loop to solve a simple problem.

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

30 min·Pairs

Pair Programming: Sum and Count Loops

Pairs receive a list of numbers and a string; first, write a for loop to sum the numbers using an accumulator. Next, adapt it to count vowels in the string. Finally, test with print statements and swap codes to debug partner's version.

Prepare & details

Explain the purpose of a 'for' loop in automating repetitive tasks.

Facilitation Tip: During Pair Programming: Sum and Count Loops, ask students to alternate the roles of 'driver' and 'navigator' every two iterations to keep both engaged and accountable for loop correctness.

Setup: Tables/desks arranged in 4-6 distinct stations around room

Materials: Station instruction cards, Different materials per station, Rotation timer

RememberUnderstandApplyAnalyzeSelf-ManagementRelationship Skills
40 min·Small Groups

Small Groups: Pattern Generators

Groups use for loops with range() to generate number patterns like multiples or stars in rows. Start by planning on paper, code in shared editor, then present one pattern to class for verification.

Prepare & details

Construct a 'for' loop to process each item in a given list.

Facilitation Tip: In Small Groups: Pattern Generators, provide pre-written starter code with intentional errors so groups must debug collaboratively before they can generate patterns.

Setup: Tables/desks arranged in 4-6 distinct stations around room

Materials: Station instruction cards, Different materials per station, Rotation timer

RememberUnderstandApplyAnalyzeSelf-ManagementRelationship Skills
25 min·Whole Class

Whole Class: Efficiency Race

Display a task like printing list items; students first write manual code individually, then rewrite with for loop. Time both approaches class-wide and discuss output matches and code length.

Prepare & details

Compare the efficiency of using a 'for' loop versus manual repetition.

Facilitation Tip: During the Efficiency Race, time each group’s manual repetition versus loop solution to make the time savings visually concrete and memorable.

Setup: Tables/desks arranged in 4-6 distinct stations around room

Materials: Station instruction cards, Different materials per station, Rotation timer

RememberUnderstandApplyAnalyzeSelf-ManagementRelationship Skills
20 min·Individual

Individual: Loop Modifications

Provide starter code with a basic for loop over a list. Students modify it three ways: reverse order, filter evens, add indices. Run and note changes in output.

Prepare & details

Explain the purpose of a 'for' loop in automating repetitive tasks.

Facilitation Tip: For Individual: Loop Modifications, circulate and listen for students explaining their changes aloud, as verbalizing logic reveals misunderstandings before coding continues.

Setup: Tables/desks arranged in 4-6 distinct stations around room

Materials: Station instruction cards, Different materials per station, Rotation timer

RememberUnderstandApplyAnalyzeSelf-ManagementRelationship Skills

Teaching This Topic

Start by modeling how to trace a 'for' loop on the board, numbering each iteration and updating variable states beside it. Avoid rushing to abstract explanations; anchor every concept to a visible sequence like letters or numbers. Research shows students grasp loop purpose faster when they first see the loop body execute for each item, so prioritize live coding with immediate output checks over slides.

What to Expect

Successful learning looks like students confidently constructing 'for' loops that correctly process each element, explaining why the loop ends, and comparing its efficiency to manual repetition. They should also articulate when to use unpacking versus range(), and trace variable states accurately after the loop.

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: Sum and Count Loops, watch for students assuming loops run forever like while loops. Redirect them by having the pair add print statements inside the loop to show each iteration and confirm the loop ends after the last item.

What to Teach Instead

During Pair Programming: Sum and Count Loops, have each pair trace their loop on paper, numbering iterations and recording the loop variable’s value after each step to prove the loop is finite and predictable.

Common MisconceptionDuring Small Groups: Pattern Generators, watch for students reusing the loop variable after the loop ends, assuming it still holds its value. Redirect them by asking the group to print the variable immediately after the loop and observe that it now contains the last item only.

What to Teach Instead

During Small Groups: Pattern Generators, require groups to insert a print statement right after the loop to verify the loop variable’s final value, reinforcing that the variable’s scope ends when the loop does.

Common MisconceptionDuring the Efficiency Race, watch for students insisting for loops only work with numbers. Redirect them by timing how long it takes to manually repeat a string operation versus coding a loop that processes each character.

What to Teach Instead

During the Efficiency Race, provide mixed data (strings, lists of mixed types) and time both manual repetition and loop solutions to demonstrate for loops iterate any sequence, not just numbers.

Assessment Ideas

Quick Check

After Pair Programming: Sum and Count Loops, give students a short code snippet with a list of integers and a for loop that prints the square of each number. Ask them to write the exact output on a sticky note and post it for immediate formative feedback.

Exit Ticket

After Small Groups: Pattern Generators, provide an exit ticket with a scenario: 'Generate the first 5 terms of the sequence 2, 4, 8, 16, ...'. Students must write a for loop using range() and explain why range() is suitable for known repetition counts.

Discussion Prompt

During the Efficiency Race, facilitate a whole-class discussion where students compare manual repetition versus for loops for printing 100 integers. Ask them to explain readability and effort differences, then vote on which method they prefer and why.

Extensions & Scaffolding

  • Challenge pairs to modify their Sum and Count Loops to handle negative numbers or empty lists, then justify their error handling in code comments.
  • Scaffolding for Pattern Generators: Provide a word bank of pattern types (pyramid, diamond, zigzag) with partially completed loops to reduce cognitive load.
  • Deeper exploration: Ask students to design a 'for' loop that counts vowels in a user-input string, then compare their solutions’ efficiency and readability in a gallery walk.

Key Vocabulary

for loopA control flow statement that allows code to be executed repeatedly. It iterates over a sequence (like a list or string) or a specified range of numbers.
iterationThe process of repeating a set of instructions or steps, typically within a loop, until a specific condition is met or a sequence is fully processed.
sequenceAn ordered collection of items, such as a string (sequence of characters) or a list (sequence of elements).
iterableAn object that can be looped over, meaning it can return its members one at a time. Lists, strings, and range objects are common iterables in Python.
range()A built-in Python function that generates a sequence of numbers, often used to control the number of times a 'for' loop executes.

Ready to teach Iteration: For Loops?

Generate a full mission with everything you need

Generate a Mission