← IGCSE Computer Science Paper 2

Writing a range condition precisely

A range check joins two comparisons with AND, so a value is valid only if both are true. Never chain them like 0 <= Mark <= 100. Use OR to test for values outside the range.

Understanding Writing a range condition precisely in IGCSE Computer Science Paper 2

What it does: Each limit gets its own full comparison with Age repeated, and AND joins them. This is the correct IGCSE pseudocode form. Exclusive limits use > and <, so 0 and 100 are rejected. Inclusive limits would use >= and <=. A range check is two separate comparisons joined by AND. Chaining like 0 <= Mark <= 100 is not allowed in IGCSE pseudocode. AND needs both comparisons to be true, so only ages from 11 to 16 pass. With OR, every number passes, because any number is at least 11 or at most 16. Outside the range means too low OR too high. No number can be below 0 and above 100 at the same time, so AND would never be true.

Common mistakes: A range check cannot be chained like 0 <= Mark <= 100. It must be two separate comparisons joined by AND: IF Mark >= 0 AND Mark <= 100. A mark cannot be below 0 and above 100 at the same time, so AND is never true. To test for values outside the range, use OR: IF Mark < 0 OR Mark > 100.

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 156–165) and word search (Modules 146–165).

Take this worksheet further — free with Cloodit

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

Learning
Duo
Which is the correct way to write a range check for a mark from 0 to 100?
Mark >= 0 AND Mark <= 1000 <= Mark <= 100
Matches
IF 0 <= Mark <= 100 THEN
↓
The comparison is chained. Pseudocode needs two comparisons joined by AND: Mark >= 0 AND Mark <= 100.
Applying
Meanings
Term
Mark >= 0 AND Mark <= 100
Meaning
A range check joins two comparisons with AND, so a value is valid only if both are true. Never chain them like 0 <= Mark <= 100. Use OR to test for values outside the range.
Practice
IF Mark >= 0 AND Mark <= 100
Testing
Gaps
IF Mark >= 0 Mark <= 100 THEN
Check Answer
Spots
2Valid ← FALSE
3IF 0 <= Mark <= 100

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

The 'Snowy Owl' badge — List Slicer, 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 is the correct way to write a range check for a mark from 0 to 100?
A. Mark >= 0 AND Mark <= 100 ✓
B. 0 <= Mark <= 100
A range check is two separate comparisons joined by AND. Chaining like 0 <= Mark <= 100 is not allowed in IGCSE pseudocode.
2. Which condition is TRUE only when Age is inside the range 11 to 16 (inclusive)?
A. Age >= 11 AND Age <= 16 ✓
B. Age >= 11 OR Age <= 16
AND needs both comparisons to be true, so only ages from 11 to 16 pass. With OR, every number passes, because any number is at least 11 or at most 16.
3. Which condition is TRUE when Mark is OUTSIDE the valid range 0 to 100?
A. Mark < 0 OR Mark > 100 ✓
B. Mark < 0 AND Mark > 100
Outside the range means too low OR too high. No number can be below 0 and above 100 at the same time, so AND would never be true.
4. A valid score must include both 1 and 10. Which condition does this?
A. Score > 1 AND Score < 10
B. Score >= 1 AND Score <= 10 ✓
Inclusive limits use >= and <=. Using > and < makes the limits exclusive, so 1 and 10 would be rejected.
5. Which condition accepts the values 1 to 9 only, so 0 and 10 are NOT valid?
A. Num >= 0 AND Num <= 10
B. Num > 0 AND Num < 10 ✓
Exclusive limits use > and <. Using >= and <= would let the limits 0 and 10 through.

Match the Pairs

Mark >= 0 AND Mark <= 100 → Valid range check: true only when Mark is from 0 to 100 inclusive, because both comparisons must be true.
Mark < 0 OR Mark > 100 → Invalid range check: true when Mark is outside 0 to 100, because only one comparison needs to be true.
Two separate comparisons joined by AND are used to check a value is within a range, never a chained comparison → Age >= 11 AND Age <= 16
Use > and < instead of >= and <= when the limits themselves are not allowed (exclusive limits) → Temp > 0 AND Temp < 100
IF 0 <= Mark <= 100 THEN → The comparison is chained. Pseudocode needs two comparisons joined by AND: Mark >= 0 AND Mark <= 100.
IF Mark >= 0 OR Mark <= 100 THEN → OR is used instead of AND, so every number passes, even -5 or 500. It should be Mark >= 0 AND Mark <= 100.

Key Term

Mark >= 0 AND Mark <= 100
A range check joins two comparisons with AND, so a value is valid only if both are true. Never chain them like 0 <= Mark <= 100. Use OR to test for values outside the range.

Fill in the Blanks

1. IF Mark >= 0 AND Mark <= 100 THEN OUTPUT "Valid mark" ENDIF
Hint: Type the logical operator that makes a mark valid only when both comparisons are true.
2. IF Mark < 0 OR Mark > 100 THEN OUTPUT "Invalid mark" ENDIF
Hint: Type the logical operator that flags a mark as invalid when either comparison is true.
3. IF Age >= 11 AND Age <= 16 THEN
Hint: Type the relational operator that includes the upper limit, so an age equal to the limit is still valid.
4. IF Mark >= 0 AND Mark <= 100 THEN
Hint: Type the variable name that must be repeated in the second comparison instead of chaining.
5. IF Temp > 0 AND Temp < 100 THEN
Hint: Type the relational operator that excludes the lower limit itself, so the limit value is not valid.

Spot the Error

Question 1
A INPUT Mark
B Valid ← FALSE
C IF 0 <= Mark <= 100
D THEN Valid ← TRUE
E ENDIF
Line C — A range check cannot be chained like 0 <= Mark <= 100. It must be two separate comparisons joined by AND: IF Mark >= 0 AND Mark <= 100.
Question 2
A INPUT Mark
B Error ← FALSE
C IF Mark < 0 AND Mark > 100
D THEN Error ← TRUE
E ENDIF
Line C — A mark cannot be below 0 and above 100 at the same time, so AND is never true. To test for values outside the range, use OR: IF Mark < 0 OR Mark > 100.
Question 3
A // Rating is 1 to 5 inclusive
B INPUT Rating
C IF Rating > 1 AND Rating < 5
D THEN OUTPUT "Valid"
E ENDIF
Line C — The limits 1 and 5 are allowed (inclusive), so >= and <= are needed. Using > and < wrongly rejects ratings of 1 and 5. It should be IF Rating >= 1 AND Rating <= 5.
Question 4
A INPUT Age
B IF Age >= 11 OR Age <= 16
C THEN OUTPUT "Accepted"
D ENDIF
Line B — A valid range needs both comparisons to be true, so they must be joined with AND. With OR, every age passes (for example 5 is <= 16 and 50 is >= 11). It should be IF Age >= 11 AND Age <= 16.
Question 5
A REPEAT
B OUTPUT "Enter mark 0-10"
C INPUT Mark
D UNTIL Mark >= 0 OR Mark <= 10
E ENDIF
Line D — The loop should repeat until the mark is inside the range, which needs both tests true, so AND. With OR the condition is always true and invalid marks are accepted. It should be UNTIL Mark >= 0 AND Mark <= 10.

Student with a class code? Join your class →