Bug hunters
1947: a computer gives wrong answers. Inside, engineers find a moth. Every mistake since has been called a bug — and finding them is a skill.
- Hunt bugs in three broken programs
- Use predict, run, spot, change one thing
- Catch a bug hiding at the edge
Bug hunters
1947: a computer gives wrong answers. Inside, engineers find a moth. Every mistake since has been called a bug — and finding them is a skill.
- Hunt bugs in three broken programs
- Use predict, run, spot, change one thing
- Catch a bug hiding at the edge
Story
Learn it
Every programmer makes mistakes. The mistakes are called bugs, after a real moth found inside a computer at Harvard in 1947, and finding and fixing them is called debugging. Good programmers are not people who never make bugs; they are people with a calm method for hunting them down. AI engineers debug too: they test a model on new examples, find where it goes wrong, and fix the data or the model.
Words to know
a mistake in a program that makes it do the wrong thing.
finding and fixing bugs.
running a program on purpose to check what it really does.
a tricky test value right at the border of a condition, like exactly 6 when the rule says more than 6.
a table where you write each bug: what should happen, what happened, what you changed, and whether it is fixed.
Step by step: the bug hunt on a triangle
The program should draw a triangle, but it draws something else:
repeat (3)
move (100)
turn ↻ (90) degrees
- Predict what should happen: a closed triangle, three equal sides.
- Run it.
- Spot the difference: three lines are drawn, but the shape does not close.
- Change one thing: the turn. To get back to the start after 3 turns you must turn all the way round, 360°, so each turn is 360 ÷ 3 = 120°. Change 90 to 120, run again, and the triangle closes. Write it in the bug log.
Why one change at a time? If you change three things and it works, you won't know which one fixed it, or whether another one broke something new.
Test different values, including the edges. A rule "more than 6 is a good apple" must be tested with 3, with 8 and with exactly 6, because that is where bugs hide.
Careful: a bug does not mean you are bad at coding. Professional programmers spend a large part of every day debugging. And change one thing at a time: change three things at once and, even if it works, you will not know which change fixed it.
Your missions
Build each program exactly as written — bugs and all. Then predict, run, spot and fix.
Bug 1 — the square that isn't
pairs5 minSupposed to: draw a square.
when green flag clicked erase all pen down repeat (3) move (100) turn ↻ (90) degrees- 1
Predict: what shape will it draw? Then run it. (How many sides does a square have?)
Only you can see this - 2
Change one thing and test again. Fill one row of your bug log.
Bug 2 — the cat that never stops
pairs5 minSupposed to: say "Salaam!" once when clicked.
when this sprite clicked forever say [Salaam!] for (1) seconds wait (1) seconds- 3
Run it. Which block keeps going and never ends? Fix it, and log it.
Bug 3 — the apple sorter that sorts wrong
pairs8 minSupposed to: say "Good apple" if the size is more than 6, otherwise "Small apple".
when green flag clicked set [size] to (8) if <(size) < (6)> then say [Good apple] else say [Small apple]- 4
Size is 8. What does it say? What should it say? Fix it.
- 5
Test it properly: size 3, size 8, and size 6. What happens at exactly 6 — is that what we want? That's an edge case.
Make your own program with one hidden bug. Swap with a partner and hunt each other's bug.
No laptop today?
The teacher writes the three programs on the board. In pairs, act each one out step by step, find the mistake, write the fix, and fill in the bug log in your notebook.
Debate it
A program that sorts apples for a fruit trader has a bug. For a week, it puts good apples in the "small" box, and the farmer is paid less. Who should fix it, and who should make things right for the farmer? Why is testing a program before people rely on it an act of amanah (trust)?
Check yourself · practice, not a test
In the app, students answer these one at a time and each answer is checked straight away. It's practice, never a mark — anything they miss comes back later for another go.
1.What is debugging?
- AWriting a program for the first time
- BFinding and fixing mistakes in a program
- CDeleting a program
- DMaking a program run faster
2.Put the bug hunt steps in order:
- 1Spot the difference
- 2Run the program
- 3Predict what should happen
- 4Change one thing and test again
3.A square is drawn with repeat (3) [move 100, turn 90]. What is wrong?
- AThe move should be 90
- BIt should repeat 4 times, not 3
- CThe turn should be 100
- DNothing is wrong
4.It is best to change many things at once when debugging, to save time.
TrueFalse5.A tricky test value right at the border of a condition, like exactly 6, is called an ______ case.
Everyone makes bugs. Good programmers find them: predict, run, spot, change one thing.
Typing practice
Practise accuracy over speed. Today, careful eyes matter more than fast fingers.
- typing.com: any lesson you have already passed, aiming for 95% accuracy or more
- Notice: when you make a typing mistake, you debug it with Backspace.
Written and designed by Faizan Ayoub. © 2026 Faizan Ayoub. All rights reserved.