Selection and repetition: IF and REPEAT in programs: what children learn
Programs are built from three main ideas. Sequence means instructions are carried out one after another, in order. Selection means the program makes a choice: IF something is true, THEN do this, ELSE do that. Repetition means instructions are repeated, using a loop such as REPEAT 4 or REPEAT UNTIL. The National Curriculum asks Key Stage 2 pupils to use all three in their programs.
In this game, children read an instruction such as “if the light is red, stop” or “repeat 4 times: move forward, turn right” and decide whether it uses selection or repetition. Every instruction in the game does one or the other, never both, so there is always a single right answer. A few extra questions check the words loop, IF, THEN, ELSE and sequence.
This topic covers a Key Stage 2 statutory requirement in the National Curriculum in England (Subject content): pupils should be taught to “use sequence, selection, and repetition in programs; work with variables and various forms of input and output”. The programme of study sets this for the whole of Key Stage 2, so schools choose when to teach it; we have placed this game in Year 3 (ages 7–8).
There is no direct equivalent in the US Common Core State Standards.
How to play
Sort the cards into the right groups. Tap a card, then its group. You can also drag a card, or press 1, 2 or 3. Each game has 3 rounds with no timer. Every card is checked as soon as you place it: a card in the wrong group comes back with a hint, and you get a point for each card you place right first time. For a quicker go, choose Quick quiz: 10 multiple-choice questions in 150 seconds (choose Relaxed for more time).
Step by step
- Look for IF. Words like “if”, “when” and “otherwise” mean the program is making a choice. That is selection.
- Look for REPEAT. Words like “repeat”, “times”, “until”, “forever” and “keep” mean something happens again and again. That is repetition.
- Act it out. Follow the instruction yourself. Did you make a choice, or did you do the same thing several times?
- Try it in code. In Scratch, find the “if … then” block and the “repeat” and “forever” blocks. Build a tiny program with each.
- Combine them. Real programs mix both: “repeat forever: if touching the wall, turn around”. Talk about which part is which.
Worked examples
Example 1: Is this selection or repetition? “If it is raining, take an umbrella.”
Working: You only take the umbrella if something is true. It is a choice.
Answer: Selection.
Example 2: Is this selection or repetition? “Repeat until you reach the wall: take a step.”
Working: You take steps again and again until the wall stops you. It is a loop.
Answer: Repetition.
Example 3: Why use REPEAT 30 instead of writing “copy” 30 times?
Working: The loop does the same job with far fewer instructions and is easy to change to 31.
Answer: It makes the program shorter and easier to change.
Common mistakes and how to fix them
- Thinking “repeat until” is selection because it checks something. It does check a condition, but its job is to keep going round. It is a loop, so it is repetition.
- Forgetting the ELSE. Ask: what should happen if the answer is no? Add an ELSE when the program needs to do something different.
- Putting instructions outside the loop. In Scratch, check which blocks are inside the repeat. Only those are repeated.
Activities to try at home
- Play “Simon says” with IF rules: “If you are wearing blue, jump.”
- Spot loops in daily life: brushing teeth, stirring, clapping a rhythm.
- Try a free block-coding app and make a sprite walk in a square with a loop.
- Print the game sheet and sort the instructions into two piles.
Ideas for the classroom
- Unplugged: one pupil is the “computer” and follows IF and REPEAT cards.
- Debug a Scratch program where the loop repeats the wrong number of times.
- Sort instruction cards into selection and repetition hoops, with a sequence line underneath.
- Use the quiz as a starter before a programming lesson.
Free printable game and worksheet
The free printable starts with a game sheet, such as a colour-by-answer picture, an answer maze or a secret-code joke, followed by a worksheet. Both use the same checked questions as the online game, and the answers are on the last page. Print it, or save it as a PDF from your browser’s print menu.
Open the free printable game and worksheet
Frequently asked questions
Where is sequence in the game?
Every program uses sequence, so it would be true of every instruction. The game asks about it in its own question instead.
Is “forever” really repetition?
Yes. A forever loop repeats until the program is stopped.
Which coding tool should we use?
Many schools use Scratch or similar block-based tools in Key Stage 2. Any tool with IF and REPEAT blocks works.