Lesson 2 of 5 · HDB Void Deck
Loops: a 45-minute coding lesson
A free 45-minute lesson on loops for ages 6–12. Students use "repeat" to water every plant along an HDB void deck corridor in a few blocks.
- 45 minutes
- Pairs, whole class
- One device per pair, plus a projector
Learning objectives
By the end of the lesson, students can:
- Recognise a pattern of instructions that repeats.
- Use a repeat loop to replace a long sequence of the same blocks.
- Put a loop inside another loop (a nested loop) to cover rows.
Key words
- Loop:
- An instruction that repeats other instructions.
- Repeat:
- Do the blocks inside a set number of times.
- Pattern:
- Something that happens again and again in the same way.
- Nested loop:
- A loop inside another loop.
You'll need
- One laptop, Chromebook or iPad per pair, open to dotcodecampus.com/maze/void-deck/1. No accounts or installs.
- A projector or screen for the demo.
- Optional: the printable unplugged grid game for the warm-up, and certificates to finish.
Lesson flow
Minutes 0–8
Unplugged warm-up
- Clap a rhythm: clap, clap, stomp, clap, clap, stomp, clap, clap, stomp. Ask students to write it down.
- Compare the long version with "repeat 3 times: clap, clap, stomp". Which is quicker to write? Which is easier to change to 10 times?
- Introduce the word loop.
Minutes 8–15
Demo on the projector
- Open HDB Void Deck level 1 (dotcodecampus.com/maze/void-deck/1). Count the squares to the lift together.
- First solve it with nine "move right" blocks, then show the one-block loop. Compare the star ratings.
- Click "Show me the Python" to show that a loop in Python is written "for i in range(9):".
Minutes 15–35
Paired play: levels 1–6
- Pairs work through levels 1–6, swapping driver and navigator at each level.
- Before building, ask pairs to say the pattern out loud, e.g. "right, water, right, water…".
- Level 6 needs a loop inside a loop. Suggest solving one row first, then wrapping it.
- Three stars on every level unlocks the bonus "Corridor Marathon".
Minutes 35–42
Class discussion
- How did you spot the part that repeats?
- Why do programmers like loops? (Shorter code, fewer mistakes, easier to change.)
- What loops do you see in daily life? (Seasons, a washing machine cycle, school timetable weeks.)
Minutes 42–45
Exit ticket
- Rewrite "right, right, water, right, right, water, right, right, water" using a repeat block.
Early finishers: Design a corridor where the plants need a nested loop, and challenge a partner to solve it in the fewest blocks.
Answer key
One three-star solution per level, in Python. Other solutions with the same number of blocks earn three stars too. Jump links take the class straight to a level.
Level 1: To the Lift
2 blocksdotcodecampus.com/maze/void-deck/1
for i in range(9):
move_right()Level 2: Thirsty Plants
3 blocksdotcodecampus.com/maze/void-deck/2
for i in range(5):
move_right()
water()Level 3: Every Other Pot
4 blocksdotcodecampus.com/maze/void-deck/3
for i in range(4):
move_right()
move_right()
water()Level 4: Staircase
4 blocksdotcodecampus.com/maze/void-deck/4
for i in range(4):
move_right()
move_down()
water()Level 5: There and Back
7 blocksdotcodecampus.com/maze/void-deck/5
for i in range(4):
move_right()
water()
move_down()
for i in range(4):
move_left()
water()Level 6: Snake Walk
9 blocksdotcodecampus.com/maze/void-deck/6
for i in range(2):
for j in range(3):
move_right()
water()
move_down()
for j in range(3):
move_left()
water()
move_down()Bonus: Corridor Marathon
4 blocksdotcodecampus.com/maze/void-deck/bonus
for i in range(4):
for j in range(3):
move_right()
water()