IF with a compound condition
A compound condition joins tests with AND, OR or NOT so one IF checks several things at once. AND needs both tests true; OR needs at least one true.
Understanding IF with a compound condition in IGCSE Computer Science Paper 2
What it does: Instead of an IF inside another IF, the AND checks both rules in a single condition, so the code runs only when both are true. A weekend is Saturday or Sunday, so only one test needs to be true. That is the job of OR, not AND. Both tests must be true, so use AND. With OR, almost every number passes (for example 5 is <= 19, and 50 is >= 13). No age is both under 12 and over 65. Qualifying for either group is enough, so use OR. Each side of AND must be a complete test. You must repeat the variable name: Mark <= 100.
Common mistakes: The IF line is missing THEN. A compound condition still needs THEN after it: IF Age >= 8 AND Ok = "Y" THEN. Each side of AND must be a full test. <= 19 has no variable, so it should be Age <= 19.
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 369–378) 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.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
IF Age >= 13 AND Age <= 19 THENFill in the Blanks
Spot the Error
Student with a class code? Join your class →