Tutorpip← About this lessonOpen the sheet →Download PDF
Ages 8+ · Coding · Finding bugs
Debugging step by step
🪨⭐🤖
Bo bumps into the rock: the dotted trail stops at the rock.
The big ideaDebug by running the steps one at a time. Find the step that goes off.

How it works

A bug is a mix-up in the steps. Bo does exactly what the steps say, so look in the steps, never at the robot.

Run the program one step at a time, and watch for the step where Bo goes off.

The bump can show up after the mix-up, so check the cards before the bump too.

Change just one step, and run it again to see whether the fix worked.

Run itOne step ata timeFind thestep thatgoes offChange onestepRun itagain
How to debug.

Example 1: Finding the bump

  1. Maya's seven cards are: forward, forward, forward, turn left, forward, forward, forward.
  2. Bo walks three steps along the bottom, and card 4 turns him to face the top.
  3. On card 5, his next forward runs into the rock.
  4. The bump shows at card 5.
1forward2forward3forward4turn left5forward6forward7forward
Card 5 is where Bo bumps.

Example 2: Looking earlier

  1. The bump came at card 5, but the mix-up was one card earlier.
  2. Card 4 turned Bo to face the top while the rock was right in front of him.
  3. Bo needed one more step along the bottom first, so the turn is too early.

Example 3: The fix

  1. Maya slides the turn card one place later in the row.
  2. Now Bo walks four steps, turns, and then walks two more.
  3. He stops right on the star.
🪨⭐🤖
Four forwards, a turn, and two more forwards.

Example 4: Why not start again

  1. Jonah says they could start again from nothing.
  2. But starting from nothing throws away steps that already work.
  3. Finding the one step that goes off is quicker.

Words to know

bug
A mix-up in the steps.
debug
To find a bug and fix it.
step
One card of the program.
run
To make the program go.

Watch out

Try it

  1. Bo bumps on card 5. Could the mix-up be on card 4?
  2. Why run a program one step at a time?
  3. Maya slides the turn card one place later. How many forwards come before the turn now?
  4. Is it quicker to start again from nothing, or to find the one step that goes off?
Answers: 1. Yes · 2. It shows the step where Bo goes off · 3. 4 · 4. Find the one step
Try at homeAsk a grown-up to say three steps, one at a time, like forward, forward, turn. You are the robot and do exactly what they say. If you end up somewhere odd, go back through the steps one at a time, find the one that went off, and fix it together. Then swap jobs!
For grown-upsPlay the Mission: say three steps one at a time, like forward, forward, turn, and let your child be the robot who does exactly what you say. If they end up somewhere odd, go back through the steps one at a time, find the one that went off, and fix it together. Then swap jobs.
Open these notes on screenScan the code, or go to tutorpip.com.