GCSE · Computer Science · Edexcel · Spec 1CP2

Programming relational operators

Same ages. Same rule shape. Change one symbol and the age of 12 flips from False to True.

Computing · Conditions

True or False? Same ages, different operator

For the rule shown, is the condition True or False when age holds this value?

Is age > 12 True or False for each age?

Still to sort

True (0)

The comparison holds for this age.

Where the line is: Read the operator, not just the numbers: the same age can sit here under one rule and in False under another.

False (0)

The comparison does not hold for this age.

Where the line is: Equal values are the troublemaker. Whether 12 lands here depends on whether the operator accepts 'equal'.

5 of 5 still to sort.

Each rule below asks one question about the value held in age. Sort every age into True or False, then switch the rule and sort the same ages again. Watch the age of 12.

Watch out: Changing > to >= changes the answer for exactly one value: 12, the boundary.

Predict, then check

Same boundary idea, mirrored. A lift sign says 'at most 8 people'.

Which condition checks that rule, with people holding the number in the lift?

Computing · Python

= or ==? What does this line really do?

A Python program contains the line age = 12

Which idea is closest to what you think that line does?
How sure are you?

Computing · Selection

Which path does the program take?

The program checks number against each condition in order. Pick a result for the first check, then the second, and see where the program ends up.

First condition (if) → Second condition (elif)

3 possible routes.

On A number arrives. 2 branches to choose from.

if number > 5: add 5, else: subtract 5. That is a two-way choice. Now slot an elif in the middle and walk each path. Only one path ever runs.

Computing · Selection in a real program

Build the password check

Complete a program that outputs Access granted if the typed password matches the stored one, and Access denied if it does not.

  1. stored_password = "blue42"The password the program already knows. The value is just an example.
  2. password = input("Enter password: ")The user's attempt goes into password.
  3. missing step
Which line is step 3?

WHAT YOU'VE LEARNED

A quick recap of today's lesson.

Compare two values, get True or False, and let that answer steer your program.

What you need to know

  • A relational operator compares two values and gives back True or False.
  • There are six: == equal to, != not equal to, < less than, <= at most, > greater than, >= at least.
  • Have a goBefore you read on: what does 7 != 7 give, True or False?

    False

    != asks 'are these different?' and 7 is not different from 7, so the answer is False.

  • In Python, == compares two values. A single = assigns, so age = 12 stores 12 in age.
  • A condition is any expression that works out to True or False, like 5 > 10 (False).
  • At the boundary, > and >= split: with age 12, age > 12 is False but age >= 12 is True.
  • Have a goYour classmate is exactly 12 and says, "I'm more than 12, so age > 12 lets me in!" Is that right? What would you change?

    No. age > 12 is False for 12. Use age >= 12.

    > leaves out the boundary value 12, while >= accepts 'equal', so it covers 12 or over.

  • Selection is for when a program has more than one possible path to follow.
  • In if, elif and else, the branch that runs is the first one whose condition returns True.
  • Have a gonumber holds 6. Both number > 5 and number > 2 are True. Which branch runs: the if, the elif, or both?

    Only the if branch.

    The first condition that returns True wins, and the program skips everything after it.

  • A password check uses if password == stored_password: to choose between Access granted and Access denied.

The big picture

Relational operators compare two values and give True or False. Use == to compare and = to assign, watch the boundary between > and >=, and use the resulting condition in selection to choose which path a program follows.

Key points

1A condition built with a relational operator always works out to True or False.
2The six operators are ==, !=, <, <=, > and >=. <= means 'at most' and >= means 'at least'.
3One = assigns a value; == compares. Mixing them up is the classic slip.
4> and >= differ for exactly one value, the boundary, so choose by whether 'equal' should count.
5In if, elif and else, the first condition that returns True decides the path and the rest are skipped.

Worked example

Problem

A shop gives free delivery when the basket total is at least 30 pounds. Write the condition, then work out what it gives for baskets of 29, 30 and 45 pounds.

⚠ Watch out

Writing = when you mean ==. A single = assigns a value, so age = 12 stores 12 in age. It does not ask whether age is 12.

🧠

Memory hook

One equals sign STORES, two equals signs ASK. And 'at least' means the boundary is in: >=.

✓

Check yourself

Without looking back: if score holds 40, what do score >= 40 and score > 40 give, and why do they differ?

Flashcards

(12)
What does a relational operator do?
It compares two values and produces True or False.
Which relational operator reads as 'at least'?
>= (greater than or equal to).
Which relational operator reads as 'at most'?
<= (less than or equal to).
What does != mean, and when is it True?
'Not equal to'. It is True when the two values are different.
In Python, what is the difference between = and ==?
= assigns a value. == compares two values and gives True or False.
What is a condition?
An expression that evaluates to True or False.
age holds 12. Is age > 12 True or False?
False. 12 is not more than 12, so the boundary value is left out.
Which condition writes the rule 'everyone aged 12 or over'?
age >= 12
In if / elif / else, which branch runs?
The first branch whose condition returns True.
Evaluate 10 == 10, 10 != 10 and 12 <= 13.
True, False, True.
When is selection used in a program?
When there is more than one possible path for the program to follow.
In the password check, what is output when password == stored_password is True?
Access granted. If it is False, the program outputs Access denied.

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

See the full Edexcel Computer Science curriculum →

How this lesson was checked. This Edexcel GCSE Computer Science (specification 1CP2)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 21 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.