← IGCSE Computer Science Paper 1

Syntax errors and run-time errors reported by translators

Code that breaks the rules of the language, like a missing bracket. The translator reports it and its line. A run-time error only occurs when the program runs.

Understanding Syntax errors and run-time errors reported by translators in IGCSE Computer Science Paper 1

What it does: The command print is misspelt as pritn. The translator does not recognise it and reports a syntax error. This code is valid, so no error is reported. Without brackets the answer is wrong, because the division is done first. This is a logic error. Translators report syntax errors and usually give the line number to help the programmer fix them. The code follows the language rules, but dividing by zero is impossible while the program is running. That is a run-time error.

Common mistakes: The closing bracket is missing, which breaks the rules of the language. This is a syntax error and the translator reports it with its line number. It should be name = input("Name: "). An if statement needs a colon at the end of the line. Without it the translator reports a syntax error on this line. It should be if age < limit:.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 430–439) and word search (Modules 419–439).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Which line contains a syntax error? A: print("Hello" B: print("Hello")
B: print("Hello")A: print("Hello" (missing closing bracket)
Matches
if age > 18 print("Adult")
↓
Syntax error: the colon is missing after the condition. The translator reports it and shows the line before the program runs.
Applying
Meanings
Term
syntax error
Meaning
Code that breaks the rules of the language, like a missing bracket. The translator reports it and its line. A run-time error only occurs when the program runs.
Practice
// Syntax error: a misspelt keyword or missing bracket
Testing
Gaps
x > 5:
Check Answer
Spots
1name = input("Name: "
2print("Hello " + name)

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Cosmic Dragon' badge — Orbit Master, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Which line contains a syntax error? A: print("Hello" B: print("Hello")
A. A: print("Hello" (missing closing bracket) ✓
B. B: print("Hello")
A missing bracket breaks the rules of the language, so it is a syntax error. The translator reports it.
2. A student types pritn("Hi") instead of print("Hi"). What kind of error is this?
A. Run-time error
B. Syntax error (misspelt keyword) ✓
A misspelt keyword breaks the language rules, so the translator reports a syntax error before the program can run.
3. What does a translator usually report when it finds a syntax error?
A. Nothing, because syntax errors are never reported
B. The error and the line number where it was found ✓
Translators report syntax errors and usually give the line number to help the programmer fix them.
4. A program runs, then crashes on the line result = 10 / 0. What type of error is this?
A. Run-time error (dividing by zero) ✓
B. Syntax error
The code follows the language rules, but dividing by zero is impossible while the program is running. That is a run-time error.
5. When does a run-time error happen?
A. Only while the program is running ✓
B. Before the program starts, while the code is being translated
Run-time errors only appear when the program is running. Syntax errors are found during translation.

Match the Pairs

print("Hi" → A syntax error: the closing bracket is missing, so the translator reports the error and its line number
result = 10 / 0 → A run-time error: the code is valid, but the program crashes when this line runs
A misspelt keyword breaks the rules of the language, so the translator reports a syntax error → pritn("Score")
A logic error gives the wrong output but no error message, because the code follows the rules → average = a + b / 2
if age > 18 print("Adult") → Syntax error: the colon is missing after the condition. The translator reports it and shows the line before the program runs.
total = 5 print(totl) → Run-time error: the variable name is misspelt, so the program stops when this line runs. The fix is to type total.

Key Term

syntax error
Code that breaks the rules of the language, like a missing bracket. The translator reports it and its line. A run-time error only occurs when the program runs.

Fill in the Blanks

1. # "iff x > 5:" is a syntax error if x > 5: print("Big")
Hint: Type the correctly spelt keyword that starts a selection statement.
2. print("Total" # Translator reports: syntax error, line 1
Hint: Type the kind of error the translator reports when a closing bracket is missing.
3. a = 10 b = 0 print(a / b) # run-time error
Hint: Type the arithmetic operator that divides a by b, causing the program to crash when run.
4. print(10 / 0) # run-time error, not syntax
Hint: Type the kind of error that only appears while the program is running (hyphenated).
5. # Want the average of 4 and 6 print(4 + 6 / 2) # logic error: prints 7
Hint: Type the kind of error that gives wrong output but no error message from the translator.

Spot the Error

Question 1
A name = input("Name: "
B print("Hello " + name)
C print("Welcome")
Line A — The closing bracket is missing, which breaks the rules of the language. This is a syntax error and the translator reports it with its line number. It should be name = input("Name: ").
Question 2
A age = 15
B limit = 18
C if age < limit
D print("Too young")
Line C — An if statement needs a colon at the end of the line. Without it the translator reports a syntax error on this line. It should be if age < limit:.
Question 3
A x = 10
B y = 2
C whlie x > y:
D x = x - y
Line C — The keyword while is misspelt. The translator does not recognise it and reports a syntax error on this line. It should be while x > y:.
Question 4
A total = 100
B people = 0
C share = total / people
D print(share)
Line B — With people set to 0, line 3 divides by zero. The code follows the rules of the language, so there is no syntax error. The program crashes with a run-time error only when it runs. It should be people = 4.
Question 5
A a = 6
B b = 8
C avg = a + b / 2
D print(avg)
Line C — Without brackets, b / 2 is worked out first, so the answer is wrong. This is a logic error: the program runs and no error message appears, but the output is incorrect. It should be avg = (a + b) / 2.

Student with a class code? Join your class →