Computing · Stage 4

Combine Loops & Choices

Coding & Systems · put a choice inside a loop, so each repeat decides for itself

✦ Computing📘 Stage 4 · S4⏱ ~11 min🧒 Ages 8–9★ Free to start
I can put a choice inside a loop.
Kavi the owl for Computing
📖

Kavi Hops the Stepping Stones

Kavi had to cross a row of stepping stones. Some stones had a shiny seed on top; some were bare. "I could write a step for every single stone," Kavi hooted, "but that's a lot!" So Kavi used a loop to visit each stone — and tucked a choice inside it: repeat for each stone: IF there is a seed, eat it · ELSE just hop. Now every turn of the loop decided for itself — eat on a seed stone, hop on a bare one. "A loop repeats the steps," said Kavi, "and the choice inside picks what to do each time!"

🎓

What your child will learn

1The loop repeats; the choice decidesThe repeat line is the loop. Inside it sits an IF … ELSE choice — the indented part is the loop's body. Every turn of the loop runs the choice again and decides fresh. Press Run and watch Kavi cross the stones.
2A loop alone, or a loop with a choice?A loop that does the same thing every turn can't handle stones that are different. Put a choice inside the loop and each repeat can decide for itself — eat here, hop there.
3How many seeds will Kavi eat?The loop visits every stone and runs the choice IF seed, eat · ELSE hop. Read the row of stones and count only the seeds, then reveal.
🔍

A peek inside

The loop is repeat for each light: IF the light is green, GO · ELSE stop. The lights are 🟢 🔴 🟢. On how many lights does Kavi GO?
the loop runs the choice on each light; GO happens only on green

Try this at home: When you put an IF/ELSE choice inside a loop, how often does the choice run?

Ready to play and learn?

Start the free interactive lesson, or print the handout for screen-free play.

Part of Computing · Stage 4 · S4 on KAVI Academy — a secular, whole-child learning platform for ages 5–12.