GCSE Computer Science

Python error types โ€” GCSE Computer Science

The three error types GCSE exams test

Every error a program can have falls into one of three categories, and GCSE exams expect you to tell them apart precisely โ€” not just recognise that "something went wrong."

Syntax errors

A syntax error means the code breaks Python's grammar โ€” a missing colon, a mismatched bracket, a misspelled keyword. Python spots syntax errors before the program ever runs; it can't even start.

if score > 50
    print("Pass")

This is missing the colon after the condition. Python won't run a single line of this program โ€” it stops at the syntax error before execution begins.

Runtime errors

A runtime error means the code is grammatically valid โ€” it starts running โ€” but crashes partway through because of something that happens while it's executing.

total = 10
count = 0
average = total / count
print(average)

This code is syntactically fine. It runs, right up until the division by zero, at which point Python raises a runtime error and the program stops. An index out of range, or casting a non-numeric string with int(), are the same category: valid code that fails on specific data.

Logic errors

A logic error is the hardest of the three to spot, because nothing crashes. The program runs from start to finish and produces an answer โ€” it's just the wrong answer.

def add(a, b):
    return a - b

result = add(3, 4)
print(result)   # prints -1, not 7

There's no syntax error and no runtime error here. The program runs perfectly and gives you an answer with total confidence โ€” it's just doing subtraction instead of addition. Python has no way of knowing that isn't what you meant.

How to identify which type a scenario describes

Work backwards from what actually happened: did the program fail to start at all (syntax)? Did it start, run for a while, then crash with an error message (runtime)? Or did it finish and print an answer, and the answer is simply wrong (logic)? That question โ€” did it crash, or did it just lie to you โ€” is the fastest way to sort the three.

Common exam mistake

Calling a logic error a runtime error because "the program crashed." Logic errors don't crash programs โ€” they produce wrong answers silently. If Python raised an exception, it's a runtime error, not a logic error.

What examiners actually test

Error questions typically describe a scenario or show a piece of code and ask you to identify which of the three error types applies, or to explain why a given error occurred. The three-way check โ€” didn't run at all, ran and crashed, ran and lied โ€” is worth memorising as a fixed checklist.

Python Coach covers hundreds of challenges taking students from their first print statement to advanced Python โ€” with progress tracking for every student.

Start your school's free trial →