← IGCSE Computer Science Paper 2

Comparison operators

Comparison operators compare two values and give TRUE or FALSE. = equal, <> not equal, < less than, > greater than, <= less than or equal, >= greater than or equal.

Understanding Comparison operators in IGCSE Computer Science Paper 2

What it does: In a condition, = compares the two values. It does not store a value (that is the job of ←). Use > when a new value must be bigger than the current one, as when finding a maximum. If Mark equals Max, the result is FALSE. Cambridge 0478 pseudocode uses <> for not equal. != is used in languages like Python, but not in the Cambridge pseudocode. The >= operator means greater than or equal to. 50 is equal to 50, so the condition is TRUE. In Cambridge pseudocode a single = tests equality inside a condition. The double == is not part of the pseudocode.

Common mistakes: The operator for 'greater than or equal to' is >=, with > first then =. => is not a valid comparison operator. It should be IF Age >= 18 THEN. A score of 50 with a pass mark of 40 is a pass, so the test must be 'greater than or equal to'. <= is the wrong way round. It should be IF Score >= Pass THEN.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 265–274) and word search (Modules 254–274).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Which operator means 'not equal to' in Cambridge pseudocode?
<>!=
Matches
IF Count => 10 THEN
↓
The operator is written the wrong way round. It should be >= (greater than or equal to), not =>.
Applying
Meanings
Term
=, <>, <, >, <=, >=
Meaning
Comparison operators compare two values and give TRUE or FALSE. = equal, <> not equal, < less than, > greater than, <= less than or equal, >= greater than or equal.
Practice
Mark ← 65
Testing
Gaps
IF Password "abc123" THEN
Check Answer
Spots
1IF Age => 18 THEN
2 OUTPUT "Adult"

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Blue-Ringed Octopus' badge — Reef Legend, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Which operator means 'not equal to' in Cambridge pseudocode?
A. !=
B. <> ✓
Cambridge 0478 pseudocode uses <> for not equal. != is used in languages like Python, but not in the Cambridge pseudocode.
2. Mark ← 50. What does the condition Mark >= 50 give?
A. TRUE ✓
B. FALSE
The >= operator means greater than or equal to. 50 is equal to 50, so the condition is TRUE.
3. Mark ← 50. What does the condition Mark > 50 give?
A. FALSE ✓
B. TRUE
The > operator means strictly greater than. 50 is not greater than 50, so the condition is FALSE.
4. Which line correctly tests whether Age is equal to 16 in a condition?
A. IF Age == 16 THEN
B. IF Age = 16 THEN ✓
In Cambridge pseudocode a single = tests equality inside a condition. The double == is not part of the pseudocode.
5. What type of value does a comparison such as Score < 40 give?
A. TRUE or FALSE ✓
B. A number
Every comparison operator compares two values and gives a Boolean result: TRUE or FALSE.

Match the Pairs

Score <> 0 → TRUE when Score is not equal to 0, FALSE when Score is 0
Age >= 16 → TRUE when Age is 16 or more, including exactly 16
A single = in a condition tests whether two values are equal and gives TRUE or FALSE → IF Password = "abc123" THEN
> is strictly greater than, so a value equal to the limit gives FALSE → IF Mark > Max THEN
IF Count => 10 THEN → The operator is written the wrong way round. It should be >= (greater than or equal to), not =>.
IF Number != 5 THEN → != is not a pseudocode operator. 'Not equal to' is written <>.

Key Term

=, <>, <, >, <=, >=
Comparison operators compare two values and give TRUE or FALSE. = equal, <> not equal, < less than, > greater than, <= less than or equal, >= greater than or equal.

Fill in the Blanks

1. IF Password = "abc123" THEN OUTPUT "Welcome" ENDIF
Hint: Type the operator that tests whether two values are equal.
2. IF Answer <> "yes" THEN OUTPUT "Try again" ENDIF
Hint: Type the operator that is TRUE when the two values are different.
3. IF Age >= 16 THEN OUTPUT "Allowed" ENDIF
Hint: Type the operator meaning greater than or equal to, so a person aged exactly 16 passes.
4. WHILE Lives > 0 DO Lives ← Lives - 1 ENDWHILE
Hint: Type the operator for strictly greater than, so the loop stops when the value reaches zero.
5. Mark ← 39 Fail ← Mark <= 39 OUTPUT Fail
Hint: Type the operator meaning less than or equal to, so the boundary value gives TRUE.

Spot the Error

Question 1
A IF Age => 18 THEN
B OUTPUT "Adult"
C ENDIF
Line A — The operator for 'greater than or equal to' is >=, with > first then =. => is not a valid comparison operator. It should be IF Age >= 18 THEN.
Question 2
A Score ← 50
B Pass ← 40
C IF Score <= Pass THEN
D OUTPUT "Pass"
E ENDIF
Line C — A score of 50 with a pass mark of 40 is a pass, so the test must be 'greater than or equal to'. <= is the wrong way round. It should be IF Score >= Pass THEN.
Question 3
A INPUT Guess
B IF Guess == 7 THEN
C OUTPUT "Correct"
D ENDIF
Line B — Cambridge pseudocode tests equality with a single =. == is used in some other languages but is not pseudocode. It should be IF Guess = 7 THEN.
Question 4
A INPUT Age
B Vote ← FALSE
C IF Age > 18 THEN
D Vote ← TRUE
E ENDIF
Line C — A person aged exactly 18 can vote, but > 18 would give FALSE for 18. Use >= to include the boundary value. It should be IF Age >= 18 THEN.
Question 5
A INPUT Name
B IF Name = Ava THEN
C OUTPUT "Hello Ava"
D ENDIF
Line B — Text being compared must be written in double quotes. Without them, Ava looks like a variable name. It should be IF Name = "Ava" THEN.

Student with a class code? Join your class →