← IGCSE Computer Science Paper 2

AND, OR and NOT

Logic operators that combine or reverse conditions: AND needs both true, OR needs one true, NOT reverses a condition. Range test: Number >= 1 AND Number <= 10

Understanding AND, OR and NOT in IGCSE Computer Science Paper 2

What it does: OR is true when at least one condition is true, so either Sat or Sun makes the whole condition true. Both comparisons must be true together for Number to be inside the range 1 to 10, which is why AND joins them. 5 >= 1 is TRUE and 5 <= 10 is TRUE. Both are true, so AND gives TRUE. 15 >= 1 is TRUE but 15 <= 10 is FALSE. AND needs both true, so the result is FALSE. A range test uses AND. With OR, almost every number passes, for example 50 is >= 1 so it would be accepted.

Common mistakes: A range test needs both conditions to be true, so it must use AND. With OR, every number passes, because each number is either at least 1 or at most 10. It should be IF Num >= 1 AND Num <= 10. AND joins two complete conditions, and the second one has lost its variable. Each side needs its own comparison: IF Age >= 13 AND Age <= 19.

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 statement about AND is correct?
Age >= 13 AND Age <= 19 is true if either test is trueAge >= 13 AND Age <= 19 is true only if both tests are true
Matches
IF Number >= 1 OR Number <= 10 THEN
↓
OR is used instead of AND, so the test is true for every number. A range test needs both conditions true, so use AND.
Applying
Meanings
Term
AND, OR, NOT
Meaning
Logic operators that combine or reverse conditions: AND needs both true, OR needs one true, NOT reverses a condition. Range test: Number >= 1 AND Number <= 10
Practice
INPUT Number
Testing
Gaps
IF Number >= 1 Number <= 10 THEN
Check Answer
Spots
2INPUT Num
3IF Num >= 1 OR Num <= 10

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

The 'Platinum Fox' badge — Tundra 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 statement about AND is correct?
A. Age >= 13 AND Age <= 19 is true if either test is true
B. Age >= 13 AND Age <= 19 is true only if both tests are true ✓
AND needs both conditions to be true. If one is false, the whole condition is false.
2. Which statement about OR is correct?
A. Day = "Sat" OR Day = "Sun" is true if at least one test is true ✓
B. Day = "Sat" OR Day = "Sun" is true only if both tests are true
OR needs only one true condition. It is false only when both conditions are false.
3. Number is 5. Which result is correct for Number >= 1 AND Number <= 10?
A. FALSE
B. TRUE ✓
5 >= 1 is TRUE and 5 <= 10 is TRUE. Both are true, so AND gives TRUE.
4. Number is 15. Which result is correct for Number >= 1 AND Number <= 10?
A. FALSE ✓
B. TRUE
15 >= 1 is TRUE but 15 <= 10 is FALSE. AND needs both true, so the result is FALSE.
5. Which is the correct range test for a number from 1 to 10 inclusive?
A. IF Number >= 1 AND Number <= 10 THEN ✓
B. IF Number >= 1 OR Number <= 10 THEN
A range test uses AND. With OR, almost every number passes, for example 50 is >= 1 so it would be accepted.

Match the Pairs

IF Age >= 13 AND Age <= 19 THEN → True only when both conditions are true, so Age is in the range 13 to 19
IF NOT (Score > 50) THEN → Reverses the condition, so it is true when Score is 50 or less
OR needs only one condition to be true, so a Day of Saturday or Sunday passes → IF Day = "Sat" OR Day = "Sun" THEN
A range test checks that Number is at least 1 and at most 10 by joining two comparisons with AND → IF Number >= 1 AND Number <= 10 THEN
IF Number >= 1 OR Number <= 10 THEN → OR is used instead of AND, so the test is true for every number. A range test needs both conditions true, so use AND.
IF Age >= 13 AND <= 19 THEN → The second condition is incomplete because Age is missing after AND. Each side of AND must be a full condition: Age <= 19.

Key Term

AND, OR, NOT
Logic operators that combine or reverse conditions: AND needs both true, OR needs one true, NOT reverses a condition. Range test: Number >= 1 AND Number <= 10

Fill in the Blanks

1. IF Number >= 1 AND Number <= 10 THEN OUTPUT "Valid" ENDIF
Hint: Type the logic operator that needs both parts of a range test to be true.
2. IF Answer = "Y" OR Answer = "y" THEN OUTPUT "Yes" ENDIF
Hint: Type the logic operator that is true when at least one condition is true.
3. IF NOT Found THEN OUTPUT "Not found" ENDIF
Hint: Type the logic operator that reverses a condition.
4. IF Number >= 1 AND Number <= 10 THEN OUTPUT "In range" ENDIF
Hint: Type the comparison operator for the upper limit of the range, so 10 is still allowed.
5. IF Score < 0 OR Score > 100 THEN OUTPUT "Invalid" ENDIF
Hint: Type the logic operator that makes the test true if the score is outside the range on either side.

Spot the Error

Question 1
A DECLARE Num : INTEGER
B INPUT Num
C IF Num >= 1 OR Num <= 10
D THEN OUTPUT "In range"
E ENDIF
Line C — A range test needs both conditions to be true, so it must use AND. With OR, every number passes, because each number is either at least 1 or at most 10. It should be IF Num >= 1 AND Num <= 10.
Question 2
A INPUT Age
B IF Age >= 13 AND <= 19
C THEN OUTPUT "Teenager"
D ENDIF
Line B — AND joins two complete conditions, and the second one has lost its variable. Each side needs its own comparison: IF Age >= 13 AND Age <= 19.
Question 3
A INPUT Mark
B IF Mark >= 0 AND Mark <= 100
C THEN OUTPUT "Valid"
D ELSE OUTPUT Invalid
E ENDIF
Line D — Text output must be in double quotes. The line should be ELSE OUTPUT "Invalid".
Question 4
A Found ← FALSE
B INPUT Name
C IF Name = "Ali" OR Name = "Bo"
D THEN Found = TRUE
E ENDIF
Line D — Assigning a value uses the arrow ←, not =. In Cambridge pseudocode = is a comparison. The line should be THEN Found ← TRUE.
Question 5
A INPUT Raining
B IF Raining NOT THEN
C OUTPUT "Go outside"
D ENDIF
Line B — NOT goes in front of the condition it reverses, not after it. It should be IF NOT Raining THEN.

Student with a class code? Join your class →