GCSE · Computer Science · AQA · Spec 8525

Less than (relational operator)

Two laps, both 49 seconds. Your program has to name the fastest lap. Does it pick the first one or the second? One symbol decides, and it's <.

Less than · inside an algorithm

Which lap was fastest?

A runner's five lap times are 52, 49, 53, 49 and 50 seconds. The program keeps the fastest time so far and the lap it happened on. Each new time is tested with time < fastest, and only a True result lets it in.

Laps 2 and 4 both took 49 seconds. Before you step through: will the program output lap 2 or lap 4?

1 fastest ← lap 1 time
2 bestLap ← 1
3 FOR lap ← 2 TO 5
4 time ← next lap time
5 IF time < fastest THEN
6 fastest ← time
7 bestLap ← lap
8 ENDIF
9 ENDFOR
10 OUTPUT bestLap
laptimetime < fastestfastestbestLap
1521

Output

 

Step 1: Lap 1 takes 52 seconds. It's the only lap so far, so it's the fastest so far.

1 / 6

Before each Next, say whether the test will be True or False and what fastest will be. Then check.

Step 1 of 6: Lap 1 takes 52 seconds. It's the only lap so far, so it's the fastest so far..

Watch out: Lap 4 ties with the fastest time so far. 49 < 49 is False, because the two values are equal and equal is not less.

Predict, then check

Loops are where < most often catches people out.

count starts at 1. The loop is WHILE count < 5, and each pass outputs count and then adds 1 to it. What is the last number this loop outputs?

Writing your own condition

Find the line that's wrong

This program should output LOW when a sensor reading is below the limit of 20. With a reading of 14 it outputs OK. Which line is wrong?

A program with one bug — which line goes wrong?

Less than in other languages

Does < look the same everywhere?

You've written IF time < fastest THEN in pseudo-code. Now you're typing the same program into a programming language.

What happens to the less-than operator? Pick the idea closest to what you think right now.
How sure are you?
UK note

AQA's pseudo-code writes less than as the symbol <.

WHAT YOU'VE LEARNED

A quick recap of today's lesson.

What you need to know

  • < is the relational operator 'less than'. It compares two values, and the result is True or False.
  • a < b is True only when a is strictly smaller than b. If the two are equal, or a is bigger, the result is False.
  • The order of the two sides matters: reading < limit and limit < reading ask reverse questions.
  • In a loop such as WHILE count < 5, the loop stops as soon as count reaches 5, so the loop body never runs with count equal to 5.
  • Different programming languages may use different symbols for less than. The meaning stays the same.

The big picture

< is the relational operator 'less than'. It compares two values and gives True only when the left value is strictly smaller than the right, so 5 < 5 is False. Order matters: a < b and b < a ask reverse questions. You'll use < in IF statements and loops in your own programs, and you need to read it correctly in algorithms. Different languages may write it with different symbols, but it always means the same thing.

Key points

17 < 9 is True, 9 < 7 is False, and 7 < 7 is False.
2With negative numbers, the value further left on the number line is the smaller one: −8 < −3 is True.
3In a 'find the lowest' algorithm, IF value < lowest only lets in a strictly smaller value. A tie keeps the first value it found.
4To check that a value is below a limit, put the value on the left: reading < limit.
5Pseudo-code, Python, Java and JavaScript all write less than as <, but each language is free to choose its own symbol.

Worked example

Problem

A cinema gives a child ticket to anyone under 12. Write the IF condition, then decide which ticket each of these customers gets: age 11, age 12 and age 13.

⚠ Watch out

Treating < as if it included equal values, for example saying 12 < 12 is True. When the two values are equal, < always gives False.

🧠

Memory hook

The pointy end of < faces the value that has to be smaller. And a tie is never smaller: equal is not less.

✓

Check yourself

Quick check, no looking back: is 6 < 6 True or False? And to test 'score is below 50', which side of < does score go on?

Flashcards

(9)
What does the operator < mean?
Less than. It's True only when the left value is strictly smaller than the right value.
What kind of result does a < comparison give?
A Boolean value: True or False.
Is 8 < 8 True or False?
False. The values are equal, and equal is not less.
Do x < y and y < x ask the same question?
No. x < y asks whether x is smaller; y < x asks whether y is smaller. If x and y are equal, both are False.
A 'find the lowest' algorithm uses IF value < lowest. What happens when a value ties with lowest?
Nothing changes. The test is False, so lowest keeps the first value it found.
In WHILE count < 10, does the loop body ever run with count equal to 10?
No. When count reaches 10, 10 < 10 is False, so the loop stops first.
Is −5 < −2 True or False?
True. −5 is further left on the number line, so it is the smaller value.
Does every programming language have to write less than as <?
No. Each language defines its own symbols, so they may differ. The meaning stays the same.
Which words in a requirement usually point to <?
'Less than', 'below', 'under' and 'fewer than'. The limit value itself does not count.

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.