← IGCSE Computer Science Paper 2

Logical operator AND

AND joins two conditions and is TRUE only when both are TRUE, e.g. Age >= 13 AND Age <= 19. If either condition is FALSE, the whole condition is FALSE.

Understanding Logical operator AND in IGCSE Computer Science Paper 2

What it does: A range check needs a lower limit and an upper limit joined by AND so both must be satisfied. 15 > 10 is TRUE but 4 > 9 is FALSE, so the whole condition is FALSE and the THEN part is skipped. Both conditions are TRUE (15 >= 13 and 15 <= 19), so AND gives TRUE. Each side of AND must be a full condition, so Mark must be repeated on both sides. One FALSE condition is enough to make an AND condition FALSE. Z > X means 2 > 5, which is FALSE. With three conditions, all three must be TRUE for AND to give TRUE.

Common mistakes: The upper limit of the range should use <=. With Age>=19 the range check is wrong, so the correct condition is Age>=13 AND Age<=19. A range check needs AND so both conditions must be TRUE. With OR every number passes. It should be IF Num>=1 AND Num<=10 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 358–368) and word search (Modules 358–378).

Take this worksheet further — free with Cloodit

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

Learning
Duo
Age <- 15. What does (Age >= 13) AND (Age <= 19) evaluate to?
TRUEFALSE
Matches
IF Age >= 13 AND <= 19 THEN
↓
The second condition is incomplete. Each side of AND must be a full condition, so Age is missing before <= 19.
Applying
Meanings
Term
AND
Meaning
AND joins two conditions and is TRUE only when both are TRUE, e.g. Age >= 13 AND Age <= 19. If either condition is FALSE, the whole condition is FALSE.
Practice
DECLARE Age : INTEGER
Testing
Gaps
IF Age >= 13 Age <= 19 THEN
Check Answer
Spots
1IF Age>=13 AND Age>=19 THEN
2 OUTPUT "Teen"

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

The 'Desert Jerboa' badge — High Jumper, 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. Age <- 15. What does (Age >= 13) AND (Age <= 19) evaluate to?
A. TRUE ✓
B. FALSE
Both conditions are TRUE (15 >= 13 and 15 <= 19), so AND gives TRUE.
2. Which statement about AND is correct?
A. TRUE when at least one condition is TRUE
B. TRUE only when both conditions are TRUE ✓
AND needs both conditions to be TRUE. 'At least one' describes OR.
3. Age <- 11. What does (Age >= 13) AND (Age <= 19) evaluate to?
A. FALSE ✓
B. TRUE
Age >= 13 is FALSE for 11, so the whole AND condition is FALSE even though Age <= 19 is TRUE.
4. Which condition correctly checks that Mark is in the range 0 to 100?
A. Mark >= 0 AND <= 100
B. Mark >= 0 AND Mark <= 100 ✓
Each side of AND must be a full condition, so Mark must be repeated on both sides.
5. Score <- 50. What does (Score > 50) AND (Score < 100) evaluate to?
A. FALSE ✓
B. TRUE
50 > 50 is FALSE (50 is not greater than 50), so the whole condition is FALSE.

Match the Pairs

Age >= 13 AND Age <= 19 → TRUE only when the age is from 13 to 19 inclusive, because both conditions must be TRUE
Score > 50 AND Score < 80 AND Passed = TRUE → A three-part AND that is TRUE only when all three conditions are TRUE
Check that a mark is in the range 0 to 100 using AND → IF Mark >= 0 AND Mark <= 100 THEN
If either condition is FALSE, the whole AND condition is FALSE → IF 15 > 10 AND 4 > 9 THEN
IF Age >= 13 AND <= 19 THEN → The second condition is incomplete. Each side of AND must be a full condition, so Age is missing before <= 19.
IF Age >= 13 OR Age <= 19 THEN → OR is used instead of AND. With OR almost every age is TRUE, so it does not check the 13 to 19 range.

Key Term

AND
AND joins two conditions and is TRUE only when both are TRUE, e.g. Age >= 13 AND Age <= 19. If either condition is FALSE, the whole condition is FALSE.

Fill in the Blanks

1. IF Age >= 13 AND Age <= 19 THEN OUTPUT "Teenager" ENDIF
Hint: Type the logical operator that is TRUE only when both conditions are TRUE
2. IF Age >= 13 AND Age <= 19 THEN OUTPUT "Teenager" ENDIF
Hint: Type the relational operator meaning less than or equal to
3. IF Score >= 0 AND Score <= 100 THEN OUTPUT "Valid mark" ENDIF
Hint: Type the keyword that closes the IF statement
4. IF Age >= 13 AND Age <= 19 THEN OUTPUT "Teenager" ENDIF
Hint: Type the highest age a teenager can be
5. IF Num > 0 AND Num < 10 AND Num <> 5 THEN OUTPUT "OK" ENDIF
Hint: Type the variable being checked in all three conditions

Spot the Error

Question 1
A IF Age>=13 AND Age>=19 THEN
B OUTPUT "Teen"
C ENDIF
Line A — The upper limit of the range should use <=. With Age>=19 the range check is wrong, so the correct condition is Age>=13 AND Age<=19.
Question 2
A INPUT Num
B Ok <- FALSE
C IF Num>=1 OR Num<=10 THEN
D Ok <- TRUE
E ENDIF
Line C — A range check needs AND so both conditions must be TRUE. With OR every number passes. It should be IF Num>=1 AND Num<=10 THEN.
Question 3
A INPUT Age
B IF Age>=13 AND <=19 THEN
C OUTPUT "Teenager"
D ENDIF
Line B — Each side of AND must be a complete condition. <=19 is missing the variable, so it should be Age<=19.
Question 4
A INPUT Temp
B INPUT Rain
C IF Temp>20 AND Rain<>0 THEN
D OUTPUT "Warm and dry"
E ENDIF
Line C — Warm and dry needs Rain to equal 0. Rain<>0 would be TRUE on a wet day. It should be Temp>20 AND Rain=0.
Question 5
A INPUT A
B INPUT B
C INPUT C
D IF A>5 AND B>5 OR C>5 THEN
E OUTPUT "All above 5"
F ENDIF
Line D — To check that all three values are above 5, every condition must be joined with AND. With OR, C>5 alone makes the condition TRUE. It should be A>5 AND B>5 AND C>5.

Student with a class code? Join your class →