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.

Python
  1. name = "Sam"
  2. score = 7
  3. print("Hello, " + name)
  4. print("Your score is, score)
  5. 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.

6 of 6 still to sort.

Syntax error detection asks one question about each line: is it written the way the language needs?

Computer Science · Syntax

Now find it with no help

This program has one syntax error and nothing is highlighted. Tap the line you think breaks the grammar rules.

A program with no editor marks on it — which line goes wrong?

Computer Science · Syntax

The editor has gone quiet

You have typed a whole program into your editor. Nothing is underlined and no line is marked.

Which of these is closest to what you think right now?
How sure are you?

Computer Science · Syntax

Describe it in your own words

A programmer is writing code in a development environment that has syntax error detection. Describe how it helps the programmer write correct code. [4 marks]

0 words · your answer stays on this page and is not sent anywhere.

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

1Syntax is the grammar rules of a programming language, and syntax error detection finds code that breaks them.
2The environment points out the faulty code and shows its line, often as you type.
3Code with a syntax error cannot be successfully translated, so the program cannot run fully until it is fixed.
4It saves searching by hand, but it only checks the grammar, not whether the result is right.

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?
A tool in a development environment, such as an IDE, that helps a programmer write correct code by finding code that breaks the language's grammar rules.
What is syntax?
The grammar rules of a programming language: they set out how its statements must be written.
Name the three syntax errors in the lesson.
A misspelt keyword, a missing bracket and a missing quotation mark.
How does a development environment point out a syntax error?
Typically by highlighting or underlining the faulty code and showing the line where it occurs.
When can a syntax error be pointed out?
Many environments check as the code is typed, so it can be flagged before the program is translated or run.
Why can a program with a syntax error not run fully?
A compiler or interpreter cannot successfully translate code that contains one.
How does syntax error detection save the programmer time?
It shows where the mistake is, so it can be corrected quickly instead of searching through the code by hand.
No syntax errors flagged. Is the program correct?
Not necessarily. The check covers only the grammar rules, so correct syntax can still give the wrong result.
A spell-checker flags a broken sentence. What is the matching idea in programming?
Syntax error detection flags a broken statement without knowing whether the program does what you meant.
Give a line that passes the syntax check but is still wrong.
total = total - score when you meant to add. It is written correctly, so it passes, and the result is 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 posted

More Eduqas GCSE Computer Science topics

See the full Eduqas Computer Science curriculum →

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.