GCSE · Computer Science · Eduqas · Spec C500QS
Syntax error detection
One missing quotation mark and, in Python, the whole program refuses to run. Your editor can point at the culprit.
Computer Science · Software tools
Meet a syntax error
This program should greet Sam and show their score. Press Run, read what the translator says about the program, then choose how to fix the line it points at.
Many editors mark a syntax error while you type, before anything is run. This practice editor shows the mark when you press Run, and every result is written in advance.
- name = "Sam"
- score = 7
- print("Hello, " + name)
- print("Your score is, score)
- print("Well done!")
The messages are what Python 3.13 prints for this exact code. Other languages and versions word them differently.
Computer Science · Syntax
Breaks the rules, or follows them?
Sort each line of Python. Ask only how the line is written, not whether it does a good job.
Still to sort
Breaks the grammar rules (0)
A syntax error: the line is not written the way the language needs.
Where the line is: It breaks the rules if the language cannot accept the way it is written, however obvious the meaning is to a human.
Follows the grammar rules (0)
Written correctly, even if it might do the wrong thing.
Where the line is: It follows the rules if the way it is written is allowed. The rules say nothing about whether the line does what you meant.
Syntax error detection asks one question about each line: is it written the way the language needs?
WHAT YOU'VE LEARNED
A quick recap of today's lesson.
The tool that spots broken grammar in your code and points at the line.
What you need to know
- Syntax error detection is a tool in a development environment, such as an IDE, that helps a programmer write correct code.
- Every programming language has syntax: the grammar rules that set out how its statements must be written.
- It finds code that breaks those rules, for example a misspelt keyword, a missing bracket or a missing quotation mark.
Have a goZara types esle: and says "close enough, everyone knows what I mean". Which of the three examples is this, and does the language accept close enough?
A misspelt keyword (else). No: the language only accepts keywords spelt its way.
Syntax is the grammar rules for how a statement must be written, and a human understanding your meaning does not satisfy them.
- When it finds one, the environment points it out, typically by highlighting or underlining the faulty code and showing its line.
- Many environments check the syntax as you type, so an error can be flagged before the program is translated or run.
Have a goNick types one line and a wavy underline appears at once. He has not pressed Run. Which must happen first for the editor to flag it: translating or running?
Neither. Many environments check the syntax as you type.
The check works on the code as it is being typed, which is why an error can be flagged before the program is translated or run. It is many environments, not necessarily all.
- A compiler or interpreter cannot successfully translate code with a syntax error, so the program cannot run fully until it is fixed.
- Because it shows where the mistake is, you can correct it quickly instead of searching through the code by hand.
- Passing it only means the grammar rules are followed; the program can still give the wrong result.
Have a goA program should double a number, but its line says answer = number + 2. Will the syntax check flag it? Decide before you reveal.
No. The line follows the grammar rules, so it passes.
The check covers only the grammar rules. It cannot know the line was meant to double, so correct syntax can still give the wrong result.
The big picture
Syntax error detection is a tool in a development environment that finds code breaking the grammar rules of the language and points out the line. A compiler or interpreter cannot successfully translate code with a syntax error, so the program cannot run fully until it is fixed. The tool shows where the mistake is, so you fix it quickly. It checks only the grammar, so code that passes can still give the wrong result.
Key points
Worked example
Problem
The editor flags line 3 of this program. price = 4 quantity = 3 total = (price * quantity print(total) Work out what to do.
⚠ Watch out
Thinking no syntax errors means the program is correct. The check covers only the grammar rules, so correctly written code can still give the wrong result.
Memory hook
Syntax is grammar. Your editor is a grammar-checker, not a mind-reader: it can tell you a statement is broken, but not whether it says what you meant.
Check yourself
A program prints 10 when it should print 12, and no syntax error was flagged. Is the syntax check at fault? Say why.
Flashcards
(10)What is syntax error detection?
What is syntax?
Name the three syntax errors in the lesson.
How does a development environment point out a syntax error?
When can a syntax error be pointed out?
Why can a program with a syntax error not run fully?
How does syntax error detection save the programmer time?
No syntax errors flagged. Is the program correct?
A spell-checker flags a broken sentence. What is the matching idea in programming?
Give a line that passes the syntax check but is still wrong.
Tap any card to flip it, or use Study as deck to go through them one at a time. In the full lesson these run as a spaced-repetition deck — you rate each card Hard, Good or Easy and the tricky ones keep coming back until they stick.
Learning with Lightbulb is opening soon
You can use this lesson now. Join the waitlist and we'll let you know when the full Lightbulb experience is ready.
Keep me postedMore Eduqas GCSE Computer Science topics
How this lesson was checked. This Eduqas GCSE Computer Science (specification C500QS)lesson was published through Lightbulb Learning's human-designed editorial process — the educational standards, accuracy rules and publication checks it must pass were authored and approved by Philip Halpin. It passed subject-specific assessment, automated educational checks and technical publication verification before going live (publication checks completed 16 November 2026). Published pages are monitored, human spot-checking is ongoing across the lesson library, and anything found wrong is corrected or withdrawn. How our lessons are made and checked. Spotted a mistake? Email hello@lightbulblearning.co and we'll review it.