Defect
Something in a program that is not the way it should be.
08BUGS Β· STEPS
A bug is a mistake in the code. The computer does exactly what we wrote, even when we meant something else. Finding bugs is a detective game.
A TRUE STORY
In 1947, a team working with the scientist Grace Hopper found a real moth stuck inside a giant computer called the Mark II. They taped it into their notebook and wrote: "First actual case of bug being found."
It was funny because engineers already called mistakes "bugs". This time, the bug was real!
Something in a program that is not the way it should be.
The nickname programmers give to a defect. Same thing, funnier word.
Hunting bugs and fixing them. De-bug: take the bug out!
BUGS IN EVERYDAY STEPS
Remember algorithms? A plan is a list of steps. A bug is a step that is wrong, missing, in the wrong place, or one that never lets the plan end.
Example: Get ready to play outside
Put on your shoes.
Put on your socks.
Go outside.
π Bug! Socks go on before shoes. This is a wrong-order bug.
YOUR TURN
Read each plan like PyBot: one step at a time, exactly as written.
PyBot's sandwich came out empty, with the jam on the outside!
Tap the step with the bug.
PyBot followed every step, but the glass is still empty.
Take a glass.
Put it under the tap.
Turn off the tap.
Drink.
What kind of bug is it?
PyBot arrived at school soaking wet.
Tap the step with the bug.
PyBot wanted 10 jumps. It is still jumping... forever!
Start counting at 0.
Jump.
Add 1 to the count.
Go back to step 2.
What does the plan need?
The bowl overflowed, and the cat stayed hungry yesterday.
Tap the step with the bug.
PyBot brushed with no toothpaste.
Take your toothbrush.
Brush your teeth.
Put toothpaste on the brush.
Rinse your mouth.
How do you squash this bug?
PyBot does exactly what the steps say. Nothing more.
Go forward 2.
Turn right.
Go forward 2.
Turn right.
Go forward 2.
What does PyBot draw?
Want a fresh start? Clear only this page.
Computers follow steps exactly. Next, you will hunt the same bugs in real Python code.