Programming with loops and choices

Ages 9 to 12 Read alone or together · about 40 minutes

Read together

A program is a set of instructions. Computers follow them exactly, in order. This is called sequence.

A loop repeats instructions: “repeat 4 times: step forward, turn right” draws a square.

A choice, or conditional, makes a decision: “if it is raining, take an umbrella, otherwise take a hat”.

Do it

  1. Play “robot”: write a program for a partner to draw a square on the floor using only the commands step forward, turn right and repeat.
  2. Make it shorter by using a loop. Count the instructions before and after.
  3. Add a choice: “if the next square is blue, turn left, otherwise go forward”. Test it on a taped grid.
  4. If you use a computer, try a block-based programming tool offline or in a class. Make a sprite draw a square with a loop.

Talk about it

For the grown-up

Sequence, loops and conditionals are the building blocks of nearly all programs. Learning them unplugged first gives children a clear idea before they use a screen. If your child uses an online coding tool, check its privacy settings.

Next lesson →

Where this comes from
  • Computer Science Teachers Association (CSTA), CSTA K-12 Computer Science Standards (2017), on algorithms and programming
  • Code.org, CS Fundamentals curriculum, unplugged and online activities on sequences, loops and conditionals

Written with AI assistance and checked against the sources listed. Please read it before sharing it with a child.