Three kinds of error
About this lesson: Three kinds of error
In short
A syntax error is like a spelling or grammar mistake in code. The program won't even start. Run it, read the message, then fix it.

What you'll explore
- Syntax errors: Breaking the language rules
- A syntax error is like a spelling or grammar mistake in code. The program won't even start. Run it, read the message, then fix it.
- Runtime errors: A crash while running
- A runtime error happens while the program runs, such as dividing by zero. The code is valid, but something impossible happens. Run it, then fix it.
- Logic errors: Runs, but wrong
- A logic error gives no message at all. The program runs but gives the wrong answer. These are the hardest to spot. Run it, then fix it.
- Check yourself: Name the error
- A program to find the area of a rectangle runs, but uses length + width instead of length × width.
Also in this lesson
- Common mix-ups
- One of each
- Error detective
Words to know
- syntax error
- Code that breaks the rules of the language.
- runtime error
- An error that crashes a program while it runs.
- logic error
- A mistake that gives wrong results without crashing.
- error message
- Text explaining what went wrong.
- exception
- Python's name for a runtime error.
Sources
- BBC Bitesize KS3 Computer Science
- Raspberry Pi Foundation, Computing curriculum resources