Example 1 — Classify three bugs in one program
Show the steps and the answer
Version A: the bracket is missing, so the code cannot be read and nothing runs. Syntax error.
The interpreter rejects the file before running any line, and its message points to the line with the missing bracket.
Version B: the code is valid and works for most classes, but with 0 scores it computes total / 0 and stops. Runtime error.
It appears only for certain inputs, so you find it by running the case that crashes, here an empty list.
Version C: it runs and prints a number with no complaint, but the number is wrong. Logic error.
Nothing stops the program, so only comparing with a hand-worked answer reveals the problem.
Check C with numbers: scores totaling 2,000 for 25 students should average 2,000 ÷ 25 = 80, but the program prints 2,000 ÷ 10 = 200.
A known answer turns 'looks fine' into a clear mismatch.
Answer: A: syntax error (read the error message). B: runtime error (run the empty-list case). C: logic error (compare with a worked answer: it prints 200 instead of 80).
Takeaway: When the error appears tells you its type: before the run is syntax, during the run is runtime, and a wrong final answer is logic.