Skip to content

Beginning of the lesson

Bugs and Debugging

Mistakes are normal — here is how to find them and fix them

Big Idea: Everyone makes mistakes when they code. A mistake in code is called a bug. Finding and fixing a bug is called debugging. You do not have to be perfect — you just have to stay calm and look carefully, one step at a time.
By the end you will be able to:
  • say what a bug and an error are in simple words,
  • explain why bugs are a normal part of coding,
  • use a simple, calm method to find and fix a bug.

1. What is a bug?

A bug is a mistake in the instructions we give a computer. The computer does exactly what the code says — so if the code has a mistake, the computer does the wrong thing. The bug is not really in the computer; it is in the steps we wrote.

Why is a mistake called a "bug"? Long ago, a real insect flew into an early computer and stopped it from working. People took the insect out and joked that they were "debugging" the machine. The funny name stuck, and today every coder in the world talks about bugs.

A bug does not mean the computer is broken. It almost always means one of our steps needs a small fix.

2. What is an error?

An error is what you notice when something goes wrong. There are two common kinds:

  • The computer stops and shows a message. It might say something like "I do not understand this line." This message is not the computer being mean — it is a helpful clue that tells you where to look.
  • The program runs, but does the wrong thing. Nothing looks broken, but the character jumps the wrong way, or the answer is not what you wanted. This is a bug too, even without a message.

Both kinds mean the same thing: there is a bug somewhere in the steps, and it is time to go find it.

Continue this lesson on YourAIZone

The full lesson has the complete explanation, worked examples, common mistakes, tests with instant checking and an AI tutor. Start right away as a guest, or create an account to keep your progress.

In the full lesson

  • The complete explanation
  • Worked examples
  • Common mistakes and how to avoid them
  • Test questions: 15
  • AI tutor that answers questions about the topic
  • Progress tracking for students, parents and teachers