Finding and fixing mistakes
Read together
When a program does not work, we say it has a bug.
Finding and fixing the bug is called debugging.
Programmers test, look closely, change one thing and test again.
Do it
- Draw a grid of 4 by 4 squares on the floor with tape or paper. Put a toy at one end and a treasure at the other.
- Write instructions to move a “robot” (a person): forward 2, turn right, forward 3.
- Follow the instructions exactly. Does the robot reach the treasure? If not, find the bug.
- Fix one step at a time and test again. Swap roles.
Talk about it
- Where was the bug?
- How did you find it?
For the grown-up
Debugging teaches that mistakes are normal and fixable. The word “bug” was used for faults in machines long before computers. A famous 1947 log entry taped a real moth found in a computer, which helped make the word famous.
← Previous lesson Next lesson →
Where this comes from
- Computer Science Teachers Association (CSTA), CSTA K-12 Computer Science Standards (2017), on debugging
- Smithsonian National Museum of American History, “First Computer Bug” (the 1947 log page with a moth from the Harvard Mark II)
Written with AI assistance and checked against the sources listed. Please read it before sharing it with a child.