Combining AND, OR and NOT with brackets
Brackets are worked out first. Without them NOT is done first, then AND, then OR. So A OR B AND C means A OR (B AND C), and brackets change that order.
Understanding Combining AND, OR and NOT with brackets in IGCSE Computer Science Paper 2
What it does: A OR B is worked out inside the brackets first, then NOT reverses the result. NOT has the highest priority, so this means (NOT A) AND B. AND is done before OR, so B AND C is grouped first. Brackets are needed to make OR go first. The brackets go first: TRUE AND FALSE is FALSE. NOT FALSE is TRUE. NOT is done first and only affects A. To negate both, write NOT (A AND B). With no brackets, AND has higher priority than OR, so B AND C is evaluated first. The programmer wants HasTicket checked for both age groups, which needs brackets around the OR part.
Common mistakes: The opening bracket has no closing bracket. Brackets must come in pairs. It should be IF (A OR B) AND C THEN so that A OR B is worked out first. No age can be both under 5 and over 64, so AND is never true and nothing would be output. To match a child or a senior it must be OR: IF Age < 5 OR Age > 64 THEN.
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.
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
(A OR B) AND CFill in the Blanks
Spot the Error
Student with a class code? Join your class →