←Previous page

08BUGS Β· STEPS

Let's go bug hunting!

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

The bug that was a real bug.

9/9/1947
First actual case of bug being found.

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!

Defect

Something in a program that is not the way it should be.

Bug

The nickname programmers give to a defect. Same thing, funnier word.

Debugging

Hunting bugs and fixing them. De-bug: take the bug out!

BUGS IN EVERYDAY STEPS

Plans can have bugs too.

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.

Wrong orderThe steps are right, but one is in the wrong place.
Missing stepSomething important was never written.
Wrong stepA step does the wrong thing, or asks the wrong question.
Never endsA step repeats and nothing tells it to stop.

Example: Get ready to play outside

  1. 1

    Put on your shoes.

  2. 2

    Put on your socks.

  3. 3

    Go outside.

Bug! Socks go on before shoes. This is a wrong-order bug.

YOUR TURN

Find the bug in the plan!

Read each plan like PyBot: one step at a time, exactly as written.

0Completed
7Not tried
0Review
01

Make a sandwich

PyBot's sandwich came out empty, with the jam on the outside!

Tap the step with the bug.

02

Get a glass of water

PyBot followed every step, but the glass is still empty.

  1. 1

    Take a glass.

  2. 2

    Put it under the tap.

  3. 3

    Turn off the tap.

  4. 4

    Drink.

What kind of bug is it?

03

Go to school in the rain

PyBot arrived at school soaking wet.

Tap the step with the bug.

04

Jump rope

PyBot wanted 10 jumps. It is still jumping... forever!

  1. 1

    Start counting at 0.

  2. 2

    Jump.

  3. 3

    Add 1 to the count.

  4. 4

    Go back to step 2.

What does the plan need?

05

Feed the cat

The bowl overflowed, and the cat stayed hungry yesterday.

Tap the step with the bug.

06

Brush your teeth

PyBot brushed with no toothpaste.

  1. 1

    Take your toothbrush.

  2. 2

    Brush your teeth.

  3. 3

    Put toothpaste on the brush.

  4. 4

    Rinse your mouth.

How do you squash this bug?

07

Draw a square

PyBot does exactly what the steps say. Nothing more.

  1. 1

    Go forward 2.

  2. 2

    Turn right.

  3. 3

    Go forward 2.

  4. 4

    Turn right.

  5. 5

    Go forward 2.

What does PyBot draw?

Your work is saved here.

Want a fresh start? Clear only this page.

!
BIG IDEA

A bug is a step that does not do what we meant.

Computers follow steps exactly. Next, you will hunt the same bugs in real Python code.