GCSE · Computer Science · AQA · Spec 8525

Less than or equal to (relational operator)

'Maximum 8 people,' says the lift sign. Eight squeeze in. Allowed? Yes: 8 is the limit, not over it. In code, 'up to and including' is one symbol: ≤.

Computer Science · Programming

Follow the loop right up to its limit

Press Next to move one step at a time. Keep your eye on the diamond when count reaches 3.

Before you start: when count reaches 3, does the path go round the loop again, or head for End? Commit to an answer, then step through.

YesNoStartcount ← 1count ≤ 3?OUTPUT countcount ← count +1End

Output

 

Step 1: Off we go. This program counts upwards, and the diamond holds the limit: 3.

1 / 13

Next moves one step, Back moves one step back, and Play runs the whole thing.

Step 1 of 13: Off we go. This program counts upwards, and the diamond holds the limit: 3..

Watch out: If the diamond said count < 3 instead, the check 3 < 3 would be False and the output would stop at 2. That little line under ≤ is what lets 3 through.

Two tests hiding in one symbol

The limit is 5. Each test gives True or False. For each value of x, tick every test that comes out True, then check.

x = 2
x = 4
x = 5
x = 8

Same test or different?

One idea, written for two different readers.

Here's one loop condition written twice. Pseudocode: WHILE count ≤ 3. Python: while count <= 3. Do these two lines test the same thing?

UK note

AQA pseudo-code writes this operator as the single symbol ≤.

Computer Science · Algorithms

Trace table — dry run the code

A new loop, traced the way you'd do it on paper. The n ≤ 8 column records every check. Predict the output before you reach the last row.

1total ← 0
2n ← 2
3WHILE n ≤ 8
4 total ← total + n
5 n ← n + 2
6ENDWHILE
7OUTPUT total
n
total
n ≤ 8
Output
Press Start to run the first line.
·

Ready when you are — step through one line at a time.

Your turn: write the condition

A quiz gives each player at most 3 attempts. The variable attempts starts at 1 and goes up by 1 after each go. (a) Using the less than or equal to operator, write the WHILE condition that keeps the quiz going while the player is still allowed an attempt. [2] (b) State how many attempts the player gets. [1] [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.

The comparison that lets the equal value through.

What you need to know

  • ≤ means 'less than or equal to'. It compares two values and gives back True or False.
  • x ≤ 5 is True when x is smaller than 5, and also when x is exactly 5.
  • Have a goQuick one before you read on: is 12 ≤ 12 True or False?

    True.

    The two values are equal, and ≤ accepts equal. Reading it as 'is 12 less than 12?' is the trap that gives False.

  • It only turns False once x is bigger than 5. So 6 ≤ 5 is False.
  • Think of ≤ as two tests joined by OR: is it less, or is it equal? One Yes is enough.
  • Order matters. x ≤ 10 asks 'is x no more than 10?', and 10 ≤ x asks a different question.
  • Have a goPick the value of x that makes x ≤ 10 True but 10 ≤ x False: 4, 10 or 15?

    4.

    10 makes both True, because equal works whichever way round. 15 only makes 10 ≤ x True. The side each value sits on changes the question.

  • In a loop controlled by WHILE count ≤ 3, the body still runs when count equals 3.
  • Swap ≤ for < and a counter that lands exactly on the limit loses that final pass.
  • Task words like 'at most', 'no more than' and 'up to and including' all point to ≤.
  • Have a goThe sign says 'No more than 6 biscuits each.' Your little brother has eaten exactly 6 and swears he's broken the rule. Write the condition that's True when someone is within the rule, using biscuits.

    biscuits ≤ 6, so he's in the clear.

    'No more than 6' includes 6 itself, so 6 ≤ 6 is True. biscuits < 6 would wrongly find him guilty.

  • Languages write this test differently. Pseudocode can use ≤; many languages, such as Python, type it as <=.

The big picture

≤ compares two values and gives True when the left value is smaller than the right one OR equal to it. Put it in an IF or a WHILE and the limit itself is included, so a loop controlled by count ≤ 3 still runs when count is 3. Languages write the same test in different ways; many type it as <=.

Key points

1≤ is 'less than' OR 'equal to': two tests joined into one.
2The equal value gets through: 5 ≤ 5 is True, but 5 < 5 is False.
3Read the condition left to right: x ≤ 10 asks 'is x no more than 10?'
4'At most', 'no more than' and 'up to and including' in a task all point to ≤.
5Swap ≤ for < and a loop whose count lands exactly on the limit stops one pass sooner.

Worked example

Problem

A cinema lets children aged 12 or under in for half price. Write an IF statement that outputs "Half price" for these children, using a variable called age.

⚠ Watch out

Treating ≤ as if it were <. When you trace WHILE count ≤ 3, it's tempting to stop the moment count reaches 3. Don't: 3 ≤ 3 is True, so the body runs once more and 3 is output.

🧠

Memory hook

≤ is just < with a line underneath, and that line is the 'or equal' part. No line, no equals, and the limit gets turned away at the door.

✓

Check yourself

No peeking: n ← 2, then WHILE n ≤ 6 the loop outputs n and adds 2. What gets output? (Answer: 2, 4, 6. 6 ≤ 6 is True, so 6 is output.)

Flashcards

(8)
What does the operator ≤ mean?
Less than or equal to.
What kind of answer does a comparison like x ≤ 5 give?
True or False.
7 ≤ 7 and 7 < 7: which one is True?
7 ≤ 7 is True and 7 < 7 is False. Only ≤ lets the equal value through.
When is x ≤ 10 False?
Only when x is bigger than 10.
How do many languages, such as Python, type ≤?
As <=, with the < first and the = second.
Which words in a task point to ≤?
'At most', 'no more than' and 'up to and including'.
In a loop with WHILE count ≤ limit, does the body run when count equals the limit?
Yes. The condition is still True, so it runs once more.
Is x ≤ 5 the same test as 5 ≤ x?
No. The order matters: 5 ≤ x asks whether 5 is no more than x.

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 26 October 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.