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.

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