Skip to content

Computer Science · Ch 5 — Getting Started with Python

Debugging

5.13

Debugging

A programmer can make mistakes while writing a program — and because of those mistakes the program may fail to execute at all, or may run but produce wrong output. Such mistakes are known as bugs or errors, and the process of identifying and removing them from a program is called debugging.

The three categories of program errors

Errors occurring in programs can be categorised as:

  1. Syntax errors — the code breaks the grammatical rules of Python, so the interpreter refuses to execute it at all (Section 5.13.1).
  2. Logical errors — the code runs to completion, but the logic is wrong, so it quietly produces an incorrect result (Section 5.13.2).
  3. Runtime errors — the code is syntactically correct and starts executing, but something goes wrong while it runs, terminating the program abnormally (Section 5.13.3). …