Revise Computing
Revision notesQuestionsFor schools
Log inStart revising free
Revision notesQuestionsFor schoolsLog in
GCSE Computer Science/Paper 2/Testing

Syntax and logic errors

Identify syntax and logic errors

2.3.2 Testing

Practise exam questions

Testing — Note 3 of 5

Syntax errors as errors which break the grammatical rules of the programming language and stop it from being run/translated; Logic errors as errors which produce unexpected output;

What you need to know

Syntax errors break the grammatical rules of a programming language and stop the program from running or being translated. Logic errors allow the program to run but produce incorrect or unexpected results. Identifying both types of error is a key skill that requires careful testing and code review.

What to know

  • Common syntax errors: misspelled keywords (printt), missing brackets, missing colons, missing quotation marks, using =< instead of <=, print(Not in demand) — missing string delimiters.
  • Syntax errors are caught by the IDE or translator and are relatively easy to fix.
  • Logic errors are harder to spot because the program does not crash — it runs but gives wrong results.
  • Testing with different types of data (normal, boundary, erroneous) helps identify logic errors.

Key terms

Syntax error

Breaks the rules/grammar of the programming language and prevents the program from running/executing/compiling.

Logic error

An error where the program runs but produces unexpected/incorrect output.

Exam technique

  • Tip:A definition requires the general rule. 'A misspelling of a keyword' is an EXAMPLE, not a definition. The definition is 'breaks the rules/grammar of the language'.
  • Tip:'Does not work' or 'stop working' are too vague — say 'prevents the program from running' (syntax) or 'produces incorrect output' (logic).
  • Example:total = num1 + num1 instead of total = num1 + num2 — using wrong variable is a logic error (line 03).
  • Example:if total >= 10 then — only checks one boundary; should be if total >= 10 AND total <= 20 then — incomplete condition is a logic error (line 04).
  • Example:for scoreCount = 1 to scores.length - 1 misses index 0; should start at 0. And scores[scoreCount] = total + total should be total = total + scores[scoreCount].
  • Example:if stocklevel >= 5 or =< 25 has THREE errors: or→AND, =<→<=, missing variable name in second comparison. Also print(Not in demand) needs quotation marks. Also output messages are swapped.

Code examples

Identifying errors
python
# SYNTAX ERROR examples:
# print("Hello"    <- missing closing bracket
# if x == 5         <- missing colon
# pritn("Hi")      <- misspelled keyword
# print(Not in demand) <- missing string quotes

# LOGIC ERROR examples:
# total = 0 inside a loop (resets each iteration)
# print("empty") prints the word, not the variable
# for i in range(1, 9) misses index 0 of an array
for i in range(9):     # Correct: starts from 0
    total = total + room[i]

Ready to test yourself?

Practise 2.3.2 questions
← Previous noteIterative, Final/terminal2.3.2 TestingNext note →Normal; Boundary; Invalid/Erroneous2.3.2 Testing

Back to Testing

Revise another OCR GCSE topic: Defensive Design

Testing

Note 3 of 5

  1. 1Testing
  2. 2Iterative, Final/terminal
  3. 3Syntax and logic errors
  4. 4Normal; Boundary; Invalid/Erroneous
  5. 5Refining algorithms
Topic overview

© 2026 Revise Computing · revisecomputing.co.uk

Privacy noticeTermsContact

Revise Computing is an independent revision resource. It is not affiliated with, or endorsed by, OCR (Oxford Cambridge and RSA Examinations).