GCSE · Computer Science · Edexcel · Spec 1CP2
Relational operators
Is a 12-year-old 'over 12'? You'd answer instantly. A program needs that question as an exact comparison with a True or False answer, and one missing symbol changes it.
Programming · Selection
One point, two different branches
Here's the same program run twice: first with a score of 10, then with 11. On each step, watch the highlighted line ask its question and get a True or False answer. (< means 'less than'; <= means 'less than or equal to'.)
Before you press Next: which line will print for a score of 10? And for 11?
1 score = int(input("Score: "))2 if score < 0:3 print("Negative")4 elif score <= 10:5 print("0 to 10")6 else:7 print("Over 10")
Variables
Output
Step 1: Run 1. Someone types 10, so score holds 10. Now the program starts asking questions: from the top, one at a time.
Step through both runs. Every True and False here is worked out for you in the notes, so check each one yourself before you read it.
Relational operators
Words into symbols
Pick a rule, then pick the operator that checks it.
Still to sort
== (0)
Where the line is: == is True only when the two values are exactly the same: 10 == 10 is True.
!= (0)
Where the line is: != is the opposite of ==. It's True whenever the two values are different, so 10 != 10 is False.
< (0)
Where the line is: < leaves the edge value out: 5 < 5 is False, because 5 isn't less than itself.
<= (0)
Where the line is: <= lets the edge value in: 5 <= 5 is True. Read it as 'at most'.
> (0)
Where the line is: > leaves the edge value out: 5 > 5 is False.
>= (0)
Where the line is: >= lets the edge value in: 5 >= 5 is True. Read it as 'at least'.
Programs can't read 'no more than 30'. Every rule has to be turned into a comparison between two values that comes out True or False. Match each rule to the one operator that checks it.
Predict, then check
Read the condition out loud as a yes-or-no question before you choose.
A club's rule is: everyone aged 12 or over can join. The program checks if age > 12. A 12-year-old tries to join. What happens?
WHAT YOU'VE LEARNED
A quick recap of today's lesson.
Every if in a program asks a yes-or-no question. Relational operators are how it asks.
What you need to know
- A relational operator compares two values and produces the result True or False.
- The six relational operators are == (equal to), != (not equal to), < (less than), <= (less than or equal to, at most), > (greater than) and >= (greater than or equal to, at least).
- An expression that uses a relational operator evaluates to True or False: age > 12 is False when age is 9 and True when age is 15.
- In Python, == is used to compare two values and = is used to assign a value to a variable. Other languages may use different symbols for these jobs.
- A condition is an expression that evaluates to True or False. Used with selection, it decides which code runs: if number > 5 the program adds 5 to number, otherwise (else) it subtracts 5.
- In if / elif / else, the conditions are checked in order and the first one that evaluates to True decides the branch taken. If none is True, the else runs.
The big picture
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) and >= (at least). A comparison such as age > 12 is a condition, and conditions drive selection: in an if / elif / else they're checked in order, and the first True one decides the branch. In Python, == compares while a single = assigns. The edge value is where > and >= disagree, so it's the value to test.
Key points
Worked example
Problem
A lift may only move when there are fewer than 8 people inside. The variable people holds how many are inside. Write the condition that allows the lift to move, then check it with 7 people and with 8 people.
⚠ Watch out
Picking > when the rule includes its edge. 'At least 50' means 50 counts, but score > 50 is False when score is 50, so a score of exactly 50 is wrongly turned away. Use score >= 50. The same slip happens with < and <= for 'at most'.
Memory hook
The little line under the symbol lets the edge in: <= and >= include the edge value, < and > shut it out. And one = stores, two == ask.
Check yourself
x holds 7. Without looking back, say whether each is True or False: x != 7, x >= 7, x < 7. Then say which operator you'd use for 'at most 7'.
Flashcards
(11)What does a relational operator do?
Which operator tests whether two values are equal?
Which operator means 'not equal to'?
Which operator means 'less than'?
Which operator means 'at most'?
Which operator means 'more than'?
Which operator means 'at least'?
In Python, what is the difference between = and ==?
What is a condition?
In if / elif / else, which branch runs?
Which value should you always test a condition with?
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 Edexcel GCSE Computer Science topics
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 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.