Tutorpip← About this lessonOpen the sheet →Download PDF
Ages 8+ · Coding · Finding bugs
Reading code out loud
1say goodbye2repeat 3 times3 spin4say hello
Read it line by line, from the top, like the robot.
The big ideaRead code out loud, one line at a time, from the top, like the robot.

How it works

Read code out loud, one line at a time, starting from the top. A computer reads it the same way.

Say what each line does, just as if you were the robot.

A line that is pushed in belongs to the line above it. A pushed-in line under repeat happens again and again.

Reading aloud slows you down, so every line gets its own turn. Skimming is quick and can skip the mistake.

A pushed-in line• belongs to the repeat above it• happens every time roundA line not pushed in• happens just once• is not part of the repeat
Pushed in, or not.

Example 1: Read it as Bo

  1. Line 1 says goodbye, so Bo says goodbye first.
  2. Line 2 says repeat 3 times, and line 3, pushed in, says spin, so Bo spins three times.
  3. Line 4 says hello, so hello comes last.
1say goodbye2repeat 3 times3 spin4say hello
What Bo does: goodbye, spin, spin, spin, hello.

Example 2: Spot the mix-up

  1. Jonah wanted hello, three spins, and then goodbye.
  2. Read aloud, Bo does goodbye, spin, spin, spin, hello.
  3. The lines are in a mixed-up order.

Example 3: A pushed-in line

  1. Line 1 says spin, so Bo spins once.
  2. Line 2 says repeat 2 times, and line 3, pushed in, says jump, so Bo jumps, and jumps again.
  3. Line 4 says wave. It is not pushed in, so Bo waves just once, at the end.
  4. Bo does: spin, jump, jump, wave.
1spin2repeat 2 times3 jump4wave
Spin, jump, jump, wave.

Example 4: Read it again

  1. A program that says hello once, spins three times and says goodbye once is: say hello, then repeat 3 times with a pushed-in spin, then say goodbye.
  2. Read it aloud: line 1 says hello, just once.
  3. Line 3 is pushed in under the repeat, so the spin happens three times.
  4. Line 4 says goodbye, once, at the end.
1say hello2repeat 3 times3 spin4say goodbye
Hello, spin, spin, spin, goodbye.

Words to know

line
One row of a program.
repeat
Does its pushed-in lines over and over.
pushed in
A line that belongs to the line above it.
order
Which line comes first, next and last.

Watch out

Try it

  1. A program says: spin, then repeat 2 times with a pushed-in jump, then wave. How many jumps does Bo do?
  2. Does a computer read a program from the top or from the last line?
  3. A line is pushed in under repeat 3 times. How many times does it happen?
  4. A program says: say hello, repeat 2 times with a pushed-in spin and jump, then say goodbye. How many moves in all?
Answers: 1. 2 · 2. From the top · 3. 3 times · 4. 6
Try at homePick a small job, like making toast or setting the table. Write three steps for it, one under another. Read them aloud to a grown-up, one line at a time, and ask them to do exactly what each line says. If it comes out odd, you have found a bug. Fix the line and read it again!
For grown-upsPlay the Mission: pick a small job like making toast, and have your child write three steps, one under another. Read them out loud and do exactly what each line says. If it comes out odd, you have found a bug, so fix the line and read it again.
Open these notes on screenScan the code, or go to tutorpip.com.