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.
Pushed in, or not.
Example 1: Read it as Bo
Line 1 says goodbye, so Bo says goodbye first.
Line 2 says repeat 3 times, and line 3, pushed in, says spin, so Bo spins three times.
Line 4 says hello, so hello comes last.
What Bo does: goodbye, spin, spin, spin, hello.
Example 2: Spot the mix-up
Jonah wanted hello, three spins, and then goodbye.
Read aloud, Bo does goodbye, spin, spin, spin, hello.
The lines are in a mixed-up order.
Example 3: A pushed-in line
Line 1 says spin, so Bo spins once.
Line 2 says repeat 2 times, and line 3, pushed in, says jump, so Bo jumps, and jumps again.
Line 4 says wave. It is not pushed in, so Bo waves just once, at the end.
Bo does: spin, jump, jump, wave.
Spin, jump, jump, wave.
Example 4: Read it again
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.
Read it aloud: line 1 says hello, just once.
Line 3 is pushed in under the repeat, so the spin happens three times.
Line 4 says goodbye, once, at the end.
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
A pushed-in line belongs to the line above it. If you forget that, you will miss the repeats.
Do not skim. Skimming is quick and can skip the mistake.
Lines in a different order can make the robot do different things.
Reading aloud is not only for beginners. Experts read code aloud too.
Try it
A program says: spin, then repeat 2 times with a pushed-in jump, then wave. How many jumps does Bo do?
Does a computer read a program from the top or from the last line?
A line is pushed in under repeat 3 times. How many times does it happen?
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.