Tutorpip← About this lessonOpen the sheet →Download PDF
Ages 8+ · Coding · Loops
Counting loops
⭐🤖
Two hops, a turn right, then four hops reach the star.
The big ideaA counting loop repeats a set number of times, counting up each round.

How it works

A counting loop repeats a set number of times.

A counter starts at zero and goes up by one each time round.

When the counter reaches your number, the loop stops.

Change the number to change how many times it repeats.

Counter at zeroDo the stepCounter up byoneReached thenumber? Stop
One counting loop.

Example 1: Five hops

  1. The course has five posts, so the program says repeat 5 times: hop.
  2. Bo hops one, two, three, four, five, and the counter reaches 5.
  3. The loop stops and Bo is on the flag.
1repeat 5 times2 hop
A counting loop for five posts.

Example 2: Change one number

  1. The flag moves farther away, so there are 9 posts.
  2. Mina does not rewrite the program. She changes the 5 to a 9.
  3. Bo hops 9 times and stops on the new flag.

Example 3: One hop too many

  1. Teo miscounts the posts and writes repeat 6 times for a course of 5 posts.
  2. Bo makes 6 hops, which is one more than 5.
  3. He bumps into the fence. The mix-up to fix: change the 6 to a 5.

Example 4: Get Bo to the star

  1. Bo starts at the bottom left, facing up. The star is at the top right.
  2. Forward 2 times brings him to the top row. Turn right makes him face along the row.
  3. Forward 4 times then brings him to the star. That is 3 blocks, because the counters do the work.
⭐🤖
Bo's route to the star.

Words to know

counting loop
A loop that repeats a set number of times.
counter
A number that starts at zero and goes up by one each time round.
repeat
Do the steps inside again.

Watch out

Try it

  1. A loop says repeat 8 times: hop. How many hops does Bo make?
  2. Where does the counter start?
  3. A loop says repeat 3 times: hop, beep. How many beeps?
  4. The loop says repeat 9 times: hop. After it, Bo hops 4 more times. How many hops in all?
  5. There are 5 posts but the loop says 7. Is the number too big or too small?
Answers: 1. 8 · 2. At zero · 3. 3 · 4. 13 · 5. Too big
Try at homeClap or hop with a grown-up and count out loud as you go. Pick a number first, like seven, and stop when you reach it. Then change the number and go again, and you have made a counting loop with your body!
For grown-upsDo the Mission: pick a number like seven, then clap or hop while counting out loud and stop when you reach it. Change the number and go again, and you have made a counting loop with your body.
Open these notes on screenScan the code, or go to tutorpip.com.