Selection and repetition: IF and REPEAT in programs

Is “if it is raining, take an umbrella” selection or repetition? A free elementary computing game about IF statements and loops, with a printable sheet.

For parents and teachers

How this game supports learning, with worked examples, common mistakes and ideas for home and school.

At a glance

Learning focus
Computer science
Suggested level
Grade 2 · Supplemental or enrichment practice
Game
Sort it out

Open the free printable game and worksheet

Selection and repetition: IF and REPEAT in programs: what children learn

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.

Suggested grade 2 practice, selected by skill and reading demand. US states and schools teach these topics in different grades; this is not a state-standards alignment claim.

CSTA 2026 PK–12 Standards teaching connection: Programming and program reasoning. This game introduces a related computing concept. Extend it with creating, testing or discussing a real example. The suggested grade is editorial; no specific CSTA performance code, certification or full coverage is claimed. Read the framework.

How to play

Sort the cards into the right groups. Tap a card, then its group. You can also drag a card, or press the number on its group. 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

  1. Look for IF. Words like “if”, “when” and “otherwise” mean the program is making a choice. That is selection.
  2. Look for REPEAT. Words like “repeat”, “times”, “until”, “forever” and “keep” mean something happens again and again. That is repetition.
  3. Act it out. Follow the instruction yourself. Did you make a choice, or did you do the same thing several times?
  4. Try it in code. In Scratch, find the “if … then” block and the “repeat” and “forever” blocks. Build a tiny program with each.
  5. 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 student 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 color-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.

How should I choose this game for my learner?

Suggested grade 2 practice, selected by skill and reading demand. US states and schools teach these topics in different grades; this is not a state-standards alignment claim.

Back to Grade 2 computing