GCSE · Computer Science · AQA · Spec 8525

Greater than (relational operator)

A rocket countdown goes 3, 2, 1... Lift off! So why does the program never say 0? One small symbol makes that decision, and it's pickier than it looks.

Greater than · Watch it decide

Why does the countdown never say 0?

Every time round, the loop asks one question: is count greater than 0? Step through and watch the answer in the count > 0 column.

Predict first: will the last number output be 1 or 0?

1 count ← 3
2 WHILE count > 0
3 OUTPUT count
4 count ← count - 1
5 ENDWHILE
6 OUTPUT 'Lift off!'
countcount > 0OUTPUT
3

Output

 

Step 1: count starts at 3. Nothing has been checked yet.

1 / 12

Use Next to step through one line at a time. Keep your eye on the count > 0 column.

Step 1 of 12: count starts at 3. Nothing has been checked yet..

Exam line: When you trace a loop, write down the condition's value (True or False) every time it's checked. The row where it turns False is where the loop ends.
Watch out: The loop stops at exactly 0, not one step later. 0 > 0 is False, because 0 is not bigger than 0.

Check your thinking

What does score > target give?

A game stores score ← 7 and target ← 7. Then it checks score > target.

Which is closest to what you think score > target gives?
How sure are you?

Predict, then check

So far you've seen > in pseudo-code. The programs you actually run are written in a programming language, like Python.

Here's one check written two ways. In pseudo-code it's IF temp > 30 THEN, and in Python it's if temp > 30: with a colon on the end. What happens to the greater than part?

Use it in your own program

The greenhouse alarm

A greenhouse program reads the temperature. If it's above 30 degrees, it should print Too hot! At exactly 30, it should stay quiet. Build the Python program line by line.

  1. limit = 30Store the limit once, so it's easy to change later.
  2. temp = float(input("Temperature: "))The reading is stored in temp as a number.
  3. missing step
Which line is step 3?

Exam line: Before you write the condition, say it as a question: 'Is temp bigger than the limit?' Then write it in that order.

WHAT YOU'VE LEARNED

A quick recap of today's lesson.

A question your program asks: is the left value bigger than the right? The answer, True or False, decides what happens next.

What you need to know

  • > is the greater than operator. It compares two values and asks: is the left value bigger than the right value?
  • It's a relational operator: an operator that compares two values. The result is a Boolean value, True or False.
  • > is strict. It's True only when the left value is bigger. If the two values are equal, the result is False: 5 > 5 is False.
  • The order matters. a > b and b > a are different questions: 9 > 4 is True, but 4 > 9 is False.
  • Programs use > in conditions. In a WHILE loop, True means go round again and False means stop. In an IF, True means run that branch.
  • Each programming language has its own rules for how its operators are written. In pseudo-code and in Python, greater than is written >.

The big picture

The greater than operator, written >, compares two values and asks: is the left value bigger than the right value? The answer is True or False. It's strict: if the two values are equal, the answer is False, and swapping the sides asks a different question. Programs use > in conditions, so the answer decides whether a loop goes round again or an IF runs its branch. Each programming language has its own rules for how its operators are written; in pseudo-code and in Python, greater than is written >.

Key points

1> asks one question: is the LEFT value bigger than the RIGHT value?
2The answer is True or False.
3Equal is not greater: 0 > 0 is False.
4Swap the sides and you change the question: 9 > 4 is True, 4 > 9 is False.
5Inside a loop or an IF, that True or False decides what the program does next.
6Read an operator by its meaning. How it's written is up to each language; here it's > in both pseudo-code and Python.

Worked example

Problem

An algorithm works through a list of four scores, nums = [4, 9, 6, 11], where nums[0] is the first score. It starts with biggest ← nums[0]. Then, for i from 1 to 3, it runs IF nums[i] > biggest THEN biggest ← nums[i]. At the end it outputs biggest. What does it output, and what job is the > doing?

⚠ Watch out

Writing the comparison the wrong way round. To ask 'is score over 50?' you need score > 50. Writing 50 > score asks the opposite question: is 50 the bigger one? Say the condition out loud as a question before you write it.

🧠

Memory hook

The wide, open end of > faces the value that has to be bigger. And it has to be BIGGER: 'as big as' doesn't count.

✓

Check yourself

In the countdown, suppose count started at 0 instead of 3. What would the program output, and why?

Flashcards

(7)
What question does a > b ask?
Is a bigger than b? It's True only if the left value is bigger than the right value.
What kind of result does a > comparison give?
A Boolean value: True or False. It doesn't give back either of the numbers.
What does 5 > 5 give?
False. The values are equal, and equal is not greater.
9 > 4 is True. What is 4 > 9?
False. Swapping the sides changes the question, so the order you write the values in matters.
What is a relational operator?
An operator that compares two values, like >, and gives True or False.
A loop starts WHILE x > 10. When does it stop going round?
The first time x > 10 is checked and gives False, so when x is 10 or less. The check happens with x's current value each time round.
What decides how the greater than operator is written in a programming language?
That language's own rules. In pseudo-code and in Python, it's written >.

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