Finding and fixing errors in algorithms

About this lesson: Finding and fixing errors in algorithms

In short

Look at each program and the error it contains.

Finding and fixing errors in algorithms

What you'll explore

Three kinds of error: Syntax, logic, runtime
Look at each program and the error it contains.
Find the first wrong step: Trace to the bug
Trace with test data until the first line gives the wrong result.
Trace tables: Check every row
Use a trace table to check an algorithm line by line.
Fix it: Runs, but wrong
Fix a logic error and run again.
Check yourself: Error type
A program to average marks crashes when the list is empty.

Also in this lesson

  • Step by step
  • Watch out for these
  • Debugging
  • More than the lesson
  • Stretch your brain
  • Try it yourself

Words to know

Syntax error
Code breaks the language rules.
Logic error
Code runs but gives wrong results.
Runtime error
Error that occurs while running.
Trace table
Table of variable values during execution.
Debugging
Finding and fixing errors.

Sources

  • Smithsonian National Museum of American History: the first computer bug
  • Python documentation: errors and exceptions
  • Raspberry Pi Foundation, Isaac Computer Science: testing and debugging
  • BBC Bitesize, GCSE Computer Science: errors

An interactive lesson with a live experiment: move the sliders, press the buttons and answer quick questions. 5 short steps and a 8-question quiz. Part of the Family plan. Written and checked by Shalo Lab. Last updated 11 November 2026.

← Solving an unseen problem · Bringing it together →

All lessons in Term 3 · Computing · Age 15