GCSE · Computer Science · Eduqas · Spec C500QS

Automatic colour coding

One missing quote mark and half your line turns the wrong colour. That is no glitch: your editor is pointing at the bug. How does it know?

Computer Science · Try it in the editor

Colours on, colours off, one missing quote

Switch Colour coding off and on and watch the code. Then press Run, read what comes back, and fix line 5.

This editor is a picture: the colours, messages and fixes are written into the lesson, not worked out live. You cannot type into it.

Python
  1. # Greet the winner
  2. name = "Sam"
  3. score = 10
  4. if score > 5:
  5. print("Well done, + name)

Every message and output here is what Python 3.13 gave for these exact lines.

How the editor decides

Which kind of part is it?

Here is one line of Python: if lives == 0: print("Game over") # no lives left. The editor has to decide a colour for each part. Which kind of part is each fragment? (Keywords, text strings and comments each get colours; numbers and identifiers may get their own too.)

Still to sort

Keyword (0)

A word that belongs to the language itself.

Where the line is: A keyword and an identifier are both words. The language reserves its keywords; an identifier is a name the programmer chose.

Identifier (0)

A name the programmer chose, such as a variable name.

Where the line is: Quote marks decide it: lives is a name, but "lives" would be a text string.

Number (0)

Digits on their own, with no quote marks.

Where the line is: A number in quote marks is not a number to the editor. It is a text string.

Text string (0)

Text between a pair of quote marks.

Where the line is: A text string starts and ends with quote marks. A comment starts with # and has no closing mark.

Comment (0)

A note for the reader, starting with #.

Where the line is: Everything after the # to the end of the line is the comment, even if it contains quote marks.

5 of 5 still to sort.

The editor never guesses. Each colour follows from how the part is written.

Predict, then check

Same program as before. This time the typo is in a name, not in a quote mark.

Line 4 should read if score > 5: but the programmer types if scroe > 5: instead. Colour coding is on. What will the editor show for scroe?

Who is doing what?

Which idea sounds closest to you?

A friend opens their program and says: "Look, my keywords, my text and my notes are all different colours!"

What do you think is going on? Pick the idea closest to yours.
How sure are you?

Say it in your own words

Why programmers like colour coding

Describe how automatic colour coding helps a programmer who is writing code. Include one example of a mistake it can help them to spot. [3 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.

Your editor colours your code for you, and it does it by following the rules of the language.

What you need to know

  • Automatic colour coding is a tool in a program development environment, such as an IDE, that helps you while you write code.
  • It's also called syntax highlighting: different parts of the code are shown in different colours, depending on what each part is.
  • You never apply the colours yourself. The editor colours each part automatically, as you type.
  • Have a goZara spends ten minutes colouring every keyword in her program by hand. Her friend's editor did the same job instantly. What is Zara missing?

    Colour coding is automatic. The editor colours each part as you type, so nobody does it by hand.

    It is a tool the development environment provides to support the programmer, not a job the programmer has to do.

  • It can do this because it recognises each part from the rules (the syntax) of the programming language.
  • Keywords, text strings and comments get different colours. Numbers and names you choose (identifiers) may get their own too.
  • The colours change only how the code looks on screen. The code, and how the program runs, stay the same.
  • Have a goYou switch colour coding off, then press Run. Predict: does the program's output change, or only how the code looks?

    Only how the code looks. The output is exactly the same.

    The colours are a display feature, so they never touch the code or how it runs.

  • Because the parts look different, each line is easier to read: you can tell its parts apart at a glance.
  • Some mistakes show up as unexpected colours, such as a misspelt keyword or a text string that has not been closed.
  • Have a goTwo lines: print("Hi") and print("Hi). Which one would show an unexpected colour, and which mistake causes it?

    print("Hi). The text string has not been closed.

    Without a closing quote the string never ends, and that is one of the mistakes that appears as an unexpected colour.

  • Only some, though. A misspelt variable name still looks like an ordinary name, so its colours look normal.

The big picture

Automatic colour coding, also called syntax highlighting, is a tool in a development environment that shows different parts of your code in different colours, according to what each part is. The editor works out each colour from the rules of the language and applies it as you type. It changes only the display, never the code or how the program runs, and it makes code easier to read and helps you spot some mistakes.

Key points

1Automatic colour coding (syntax highlighting) shows each part of the code in a colour that matches what the part is, with no effort from the programmer.
2The development environment recognises the parts from the syntax of the language and colours them as the code is typed.
3It changes only the display, never the code or how the program runs.
4It makes code easier to read and helps spot some mistakes, but not all of them.

Worked example

Problem

Priya means to type the keyword while at the start of a line, but she types whlie lives > 0: by mistake. Use the colours to track down what is wrong.

⚠ Watch out

Treating normal-looking colours as proof that the code is right. Colour coding shows only some mistakes, and a misspelt variable name looks like any other name.

🧠

Memory hook

Paint, not program. The editor paints colours onto the screen using the language's rules. Wipe the paint off and the program underneath is exactly the same.

✓

Check yourself

Why does a misspelt whlie look odd in the editor, but a misspelt scroe usually does not? (Answer: whlie is not a keyword, but scroe still looks like a name.)

Flashcards

(11)
What is automatic colour coding?
A tool in the development environment that shows different parts of the code in different colours, without the programmer applying them.
What is another name for automatic colour coding?
Syntax highlighting.
What does IDE stand for?
Integrated development environment: a program development environment used to write code.
Who or what applies the colours, and when?
The development environment, automatically, as the code is typed.
How does the editor know which colour each part needs?
It recognises each part from the rules (the syntax) of the programming language.
Name three parts of code that get different colours.
Keywords, text strings and comments. Numbers and identifiers may have their own colours too.
What is the difference between a keyword and an identifier?
A keyword is a word that belongs to the language itself. An identifier is a name the programmer chooses, such as a variable name.
What does colour coding change?
Only how the code is displayed on screen. The code and how the program runs stay the same.
How does colour coding make code easier to read?
Different parts of each line look different, so they can be told apart at a glance.
Give two mistakes that can show up as an unexpected colour.
A misspelt keyword, and a text string that has not been closed.
Do normal-looking colours prove the code has no mistakes?
No. Colours reveal only some mistakes. A misspelt variable name, for example, looks like an ordinary name.

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 15 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.