Skip to content
Technologies · Year 7

Active learning ideas

Loops: For and While

Active learning works for loops because students need to physically trace iterations and watch variables change in real time. This makes abstract control flow visible and memorable, turning 'what happens next' into something they can see and touch.

ACARA Content DescriptionsAC9TDI8P03
25–45 minPairs → Whole Class4 activities

Activity 01

Project-Based Learning30 min · Pairs

Pair Programming: Basic Loop Challenges

Pairs write a 'for' loop to print numbers 1-20 with a message. Next, code a 'while' loop for a simple guessing game where the program counts attempts until correct. Partners alternate coding and testing, then explain their code to each other.

Design a program that uses a loop to iterate through a sequence.

Facilitation TipDuring Pair Programming: Basic Loop Challenges, circulate and ask each pair to orally explain their loop’s exit condition before they run the code.

What to look forProvide students with two short code snippets, one using a 'for' loop and one using a 'while' loop, each designed to perform a similar task (e.g., printing numbers). Ask students to write one sentence explaining which loop is more appropriate for the task and why.

ApplyAnalyzeEvaluateCreateSelf-ManagementRelationship SkillsDecision-Making
Generate Complete Lesson

Activity 02

Project-Based Learning45 min · Small Groups

Small Groups: Nested Loop Patterns

Groups use nested 'for' loops to create shapes like triangles or squares with asterisks. They modify code to change size or add colors, predict outputs first, then run and share screens. Discuss why nesting multiplies iterations.

Compare the appropriate use cases for 'for' loops and 'while' loops.

Facilitation TipWhen students complete Small Groups: Nested Loop Patterns, have them tape their final grid to the board and annotate the inner and outer loop ranges with colored markers.

What to look forPresent students with a simple nested loop structure (e.g., printing a small grid of asterisks). Ask them to predict and write down the exact output of the code before running it. Review their predictions as a class.

ApplyAnalyzeEvaluateCreateSelf-ManagementRelationship SkillsDecision-Making
Generate Complete Lesson

Activity 03

Project-Based Learning25 min · Whole Class

Whole Class: Loop Prediction Relay

Display 4-5 code snippets with loops on the board. Students write predicted outputs individually, then relay answers in a chain to the front. Run code as a class to verify and trace errors together.

Predict the output of a program containing nested loop structures.

Facilitation TipFor Loop Prediction Relay, assign each student a step in the relay so every mind is engaged in tracing one iteration at a time aloud.

What to look forPose the scenario: 'You need to write a program that asks a user for a password until they enter the correct one.' Ask students to explain which type of loop ('for' or 'while') would be best suited for this task and why, focusing on the condition that would control the loop.

ApplyAnalyzeEvaluateCreateSelf-ManagementRelationship SkillsDecision-Making
Generate Complete Lesson

Activity 04

Project-Based Learning35 min · Individual

Individual: Loop Data Processor

Students code a 'for' loop to process a list of test scores, calculating averages. Add a 'while' loop to keep asking for new scores until 'done' is entered. Submit and self-assess predictions vs. actual output.

Design a program that uses a loop to iterate through a sequence.

What to look forProvide students with two short code snippets, one using a 'for' loop and one using a 'while' loop, each designed to perform a similar task (e.g., printing numbers). Ask students to write one sentence explaining which loop is more appropriate for the task and why.

ApplyAnalyzeEvaluateCreateSelf-ManagementRelationship SkillsDecision-Making
Generate Complete Lesson

A few notes on teaching this unit

Teach loops by starting with unplugged role-plays to build mental models of iteration. Once students can act out a loop, move to tracing short snippets on paper before coding. Emphasize that 'for' loops are for known counts and 'while' loops are for unknown counts that depend on a changing condition. Avoid rushing to syntax; focus on the purpose of the loop first.

Successful learning looks like students confidently choosing between 'for' and 'while' loops based on task requirements and correctly predicting nested loop outputs without running the code. They should explain their reasoning clearly and debug loop errors by identifying missing condition updates or incorrect ranges.


Watch Out for These Misconceptions

  • During Small Groups: Nested Loop Patterns, watch for students writing two separate loops that run one after the other instead of nesting them.

    Have the group trace the outer loop once on paper, then ask them to imagine what the inner loop must do before moving on to the next outer iteration. Use physical tiles to build the grid step by step to reinforce the multiplication of runs.

  • During Pair Programming: Basic Loop Challenges, watch for students assuming 'for' loops always start at 1 and count up by 1.

    Provide starter code with negative ranges or list names, then ask the pair to change the loop to iterate backwards. Before coding, ask them to predict the output and discuss how the range flexibility supports different tasks.

  • During Whole Class: Loop Prediction Relay, watch for students treating the 'while' loop as if it only checks the condition once at the start.

    Use a role-play where the condition is a student holding a sign that changes value only after the loop body runs. Pause after each body step to ask if the condition is still true, making the dynamic check visible.


Methods used in this brief