Studyfin Studyfin ✨ Sign up free

Debugging

Grade 8 · Coding · Free lesson

Welcome! Today we will become code detectives and learn how to debug algorithms.

An algorithm is a step-by-step list of instructions for a computer. A bug is an error in those instructions that makes the program fail.

kids

Debugging means finding and fixing errors in your code. We test each step one by one to see where things go wrong.

Step 1: Move Forward Step 2: Turn Left

To debug effectively, trace your program carefully. Compare what your code actually does with what you wanted it to do.

✏️ Worked example

Debug this algorithm for making cereal: 1. Pour milk into bowl. 2. Eat cereal. 3. Pour cereal into bowl.

  1. Read through all the steps in order.
  2. Identify the error: Step 2 tells you to eat before adding cereal.
  3. Remove the incorrect step placement.
  4. Reorder the steps: 1. Pour cereal, 2. Pour milk, 3. Eat cereal.
  5. Test the new sequence to confirm it works.
code
Want the full interactive lesson — quiz, animations, and Finn cheering them on?

More Coding lessons