Computing · Stage 6

Challenge: Debug the Broken Program

Programs & Judgement · challenge · find the bug in a broken program and fix it

✦ Computing📘 Stage 6 · S6⏱ ~13 min🧒 Ages 10–12★ Free to start
I can find the bug and fix a broken program.
Kavi the owl for Computing
📖

Kavi Hunts the Bug

Kavi's little tea program would not work — the cup came out empty and cold every time. "A program that does the wrong thing has a bug in it," said Kavi, "and a good coder does not panic — a good coder hunts it." Kavi read the steps one line at a time, in order: boil the water … good … put the tea bag in … good … pour cold water on the floor — there! One line was doing the wrong thing. Kavi changed just that line to pour the hot water into the cup, pressed ▶ Run again, and out came a warm cup of tea. "Find the one wrong line, fix it, and run it again to check," Kavi hooted. "That is how you debug."

🎓

What your child will learn

1Four moves to hunt a bugA bug is a mistake in the steps that makes a program do the wrong thing. You do not fix it by guessing — you debug it with four moves. Tap each one to hear its job.
2One line is doing the wrong thingHere is Kavi's broken tea program. Press ▶ Run and watch it step through — the third line is the bug: it pours cold water on the floor instead of hot water in the cup.
3Name the bug before you fix it
4Why not just change lines at random?When a program is broken you could change bits and hope — or you could debug it properly. Tap each way to compare.
5Hunt the bug in each little programRead each broken program, find the one thing that is wrong, and predict what happens. Reveal to check the fix, then try the next.
🔍

A peek inside

A program should count down 3, 2, 1: say 3 · say 2 · say 5. Find the bug.
read each line in order — 3 is right, 2 is right, but 5 is not

Try this at home: A mistake in a program that makes it do the wrong thing is called a ____.

Ready to play and learn?

Start the free interactive lesson, or print the handout for screen-free play.

Part of Computing · Stage 6 · S6 on KAVI Academy — a secular, whole-child learning platform for ages 5–12.