GCSE · Computer Science · AQA · Spec 8525

Equal to (relational operator)

The line score = 10 asks a question in one language and gives an order in another. Today you'll learn to tell which, and why it matters.

Computer Science · Programming

One question, asked three times

A guess-the-number game. The secret is 7, and the player types 3, then 9, then 7. Step through and watch the column headed guess = secret.

Every time line 4 lights up, say True or False out loud before you press Next.

1 secret ← 7
2 REPEAT
3 guess ← USERINPUT
4 UNTIL guess = secret
5 OUTPUT 'Correct!'
secretguessguess = secretOUTPUT
7

Output

 

Step 1: Line 1 is an assignment. Read the arrow as an order: store 7 in secret. A variable has changed, so 7 goes in its column.

1 / 8

Press Next one step at a time. Predict every guess = secret answer before it appears.

Step 1 of 8: Line 1 is an assignment. Read the arrow as an order: store 7 in secret. A variable has changed, so 7 goes in its column..

Exam line: When you dry-run a condition, work out True or False from the values the variables hold at that moment. Then follow where that answer sends the program.
Watch out: Look along each guess = secret row. The guess and secret cells are empty, because in a trace table you only write a value when it changes, and asking the question changes nothing.

Same symbol, different job

Does this line ask, or does it store?

Put each line in the right column. Does it ask whether two values are equal, or does it store a value in a variable?

Still to sort

Asks: are these two values equal? (0)

Gives True or False. No variable changes.

Where the line is: If the line checks two values and nothing is being put into a variable, it's asking.

Stores a value in a variable (0)

An order. The variable on the left now holds a new value.

Where the line is: If a variable ends up holding something new, the line is storing, whatever symbol it uses.

6 of 6 still to sort.

Each line is labelled with its language. The symbol = turns up in both languages, but it does not do the same job in both.

Watch out: Don't decide from the symbol alone. The same = asks a question in pseudo-code and gives an order in Python.
UK note

AQA's exam pseudo-code writes assignment as ← and equal to as =. In your own programs, use the symbol your programming language uses for equal to.

Spot the bug

Why won't it let me in?

This pseudo-code should output 'Welcome back' when the PIN typed matches the stored PIN. Someone types 4071, the right PIN, and nothing is output. Which line is wrong?

A program with one bug — which line goes wrong?

Exam line: When a program gives the wrong result, check every = and ←. Ask whether each line should be asking a question or storing a value.

Your turn

Write a match checker

Write an algorithm in pseudo-code that asks the user to type two words. It should output 'Match' if the two words are the same, and 'No match' if they are not. [4 marks]

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

Exam line: Credit comes from each part separately: storing the inputs, a correct equal-to condition, and the right output in each case.

WHAT YOU'VE LEARNED

A quick recap of today's lesson.

It compares two values, answers True or False, and changes neither of them. That answer decides what the program does next.

What you need to know

  • Equal to compares two values. It gives True if they are the same and False if they are not.
  • Checking a condition never changes a variable. Only assignment (← in pseudo-code) stores a value.
  • The True or False answer decides what runs next, such as which part of an IF runs or whether a loop goes round again.
  • Different languages use different symbols. Pseudo-code writes equal to as =. Python writes it as ==, because Python's = means assignment.

The big picture

Equal to is a relational operator. It compares two values and gives True if they are the same and False if they are not. It never changes either value, and its answer decides what the program does next. Pseudo-code writes equal to as = (and assignment as ←). Python writes it as ==, because Python's = means assignment.

Key points

1Read = in a pseudo-code condition as a question: 'is guess equal to secret?'
2Read ← as an order: 'store 7 in secret'.
3A False answer is not an error. The program just takes the other path.
4Before you decide what = does in a line, check which language it's written in.

Worked example

Problem

Dry-run this pseudo-code when the user types 12. What does it output? target ← 10 entry ← USERINPUT IF entry = target THEN OUTPUT 'Exactly right' ELSE OUTPUT 'Not quite' ENDIF OUTPUT entry

⚠ Watch out

Treating = in a condition as if it sets the variable. IF score = 10 THEN doesn't put 10 in score. It asks whether score already holds 10. The mirror-image slip is writing = where you meant to store a value, so the variable never changes.

🧠

Memory hook

Arrow stores, equals asks. And in Python: one = stores, two == ask.

✓

Check yourself

Without looking back: in pseudo-code, what is the difference between total ← 0 and IF total = 0 THEN? Now say how you'd write each of those two lines in Python.

Flashcards

(7)
What does the equal to operator do?
It compares two values and gives True if they are the same, False if they are not.
Does checking guess = secret change guess or secret?
No. A condition only reads the values. Only an assignment changes a variable.
In pseudo-code, which symbol means equal to, and which means assignment?
= means equal to. ← means assignment (store a value).
How does Python write equal to, and why isn't it just =?
Python writes equal to as ==, because in Python = already means assignment.
What does the True or False answer of an equal-to condition do?
It decides what the program does next, such as which part of an IF runs or whether a loop repeats.
How should you read IF a = b THEN aloud?
'If a is equal to b, then…' It's a question, not an order to make a equal to b.
A Python line reads if level = 3: — what's wrong?
In Python, = stores a value. To ask whether level is equal to 3 it needs ==, so: if level == 3:

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 AQA GCSE Computer Science topics

See the full AQA Computer Science curriculum →

How this lesson was checked. This AQA GCSE Computer Science (specification 8525)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 29 September 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.