Patterns, Sequences & Loops
PrimaryA pattern is something that repeats in a predictable way — red, blue, red, blue, red, blue. A sequence is a list of things in a particular order. When part of a sequence repeats over and over, we call that repeating part a loop.
Instead of writing "clap, clap, stomp" four separate times, we can say: repeat "clap, clap, stomp" 4 times. That single instruction is a loop — it says how many times to do something, so we don't have to write it out again and again.
Loops save enormous effort. Imagine writing a separate instruction for a robot to take each of 100 steps forward — one hundred lines that all say the same thing! A loop lets us say it once: "take a step, and do that 100 times." Real computer programs use loops constantly, from games that check every second whether you pressed a key, to a washing machine that repeats its spin cycle.
Big idea. Whenever you find yourself repeating the exact same instruction again and again, that's a sign a loop could do the job in one line instead.
Activity: Pattern Beads. Using two colours of beads (or two crayons), make a pattern that repeats: red, red, blue — red, red, blue — red, red, blue. Say out loud: "repeat red-red-blue, three times." Then invent your own repeating pattern and challenge a partner to guess the loop instruction that makes it.
Bonus: Clap Loop. Stand in a circle. One person calls out a loop like "repeat clap-clap-stomp, 4 times" and everyone performs it together, counting the repeats out loud.
Q1 What is a loop?
A loop is an instruction to repeat a set of steps a certain number of times (or until something happens), instead of writing those steps out over and over.
Q2 Why do programmers use loops instead of writing the same instruction many times?
It saves a lot of writing, and it's easier to fix — if you need to change what happens each time, you only fix it in one place instead of a hundred copies.
Q3 Can you think of a loop from real life?
A washing machine repeats "fill, wash, drain, spin" until it's done. A merry-go-round repeats the same circle again and again. Both are loops — a set of steps happening over and over.
How the ideas connect
Every key idea in this chapter, branching from the core concept — use it to see the whole picture at a glance.
The process, step by step
Worked problems, step by step
Follow each solution line by line, then try to reproduce it on paper before moving on.
Example 1Rewrite this using a loop: step, step, step, step (four times).
- Notice the same step repeats four times.
- Collapse it into one instruction.
Example 2A loop says "repeat 3 times: clap". How many claps happen?
- The body is one clap.
- It runs 3 times.
Now you try
Work each one out first, then tap to reveal the worked answer.