GCSE Revision Aid: This resource is designed to support your revision and may contain errors. If you find a discrepancy with your class teaching, your teacher is correct — please let us know at gcserevise@scott.scottrix.co.uk.

CS9: Boolean Operations

Foundation Higher AQAEdexcelOCREduqasCCEA

Master NOT, AND, OR truth tables, combining Boolean operators in conditions, De Morgan's Laws, and operator precedence.

Fastmail

📋 What are Boolean Operations?

Boolean operations work on Boolean values (TRUE and FALSE) to produce a Boolean result. They are used to combine or invert conditions in IF statements and WHILE loops.

The three Boolean operators are:

🔄 NOT

NOT reverses a Boolean value. NOT TRUE = FALSE, NOT FALSE = TRUE. It is used to invert a condition.
ANOT A
TRUEFALSE
FALSETRUE
NOT in Pseudo-code
isRaining ← TRUE
IF NOT isRaining THEN
    OUTPUT "Let's go outside!"
ELSE
    OUTPUT "Stay inside"
ENDIF
// Output: "Stay inside" (because NOT TRUE = FALSE)

🔗 AND

AND returns TRUE only when BOTH conditions are TRUE. If either one is FALSE, the result is FALSE.
ABA AND B
TRUETRUETRUE
TRUEFALSEFALSE
FALSETRUEFALSE
FALSEFALSEFALSE
AND in Pseudo-code
IF age >= 18 AND hasID = TRUE THEN
    OUTPUT "You can buy alcohol"
ELSE
    OUTPUT "You cannot buy alcohol"
ENDIF
// Both conditions must be TRUE to allow the purchase
AND Rule:
Think of AND as a strict gatekeeper.
TRUE AND TRUE = TRUE (both pass)
Anything else = FALSE (at least one fails)

🔀 OR

OR returns TRUE when at least ONE condition is TRUE. Only returns FALSE when BOTH conditions are FALSE.
ABA OR B
TRUETRUETRUE
TRUEFALSETRUE
FALSETRUETRUE
FALSEFALSEFALSE
OR in Pseudo-code
IF day = "Saturday" OR day = "Sunday" THEN
    OUTPUT "It's the weekend!"
ELSE
    OUTPUT "It's a weekday"
ENDIF
// Only one condition needs to be TRUE
OR Rule:
Think of OR as a lenient gatekeeper.
FALSE OR FALSE = FALSE (both fail)
Anything else = TRUE (at least one passes)

🧮 Combining Boolean Operators

You can combine multiple Boolean operators in a single condition. Use brackets to make the order of evaluation clear.
Combining AND and OR
IF (age >= 18 AND hasID = TRUE) OR isMember = TRUE THEN
    OUTPUT "Access granted"
ENDIF

Access is granted if: (over 18 AND has ID) OR is a member.

Complex Condition
IF (score >= 70 OR coursework >= 80) AND attendance >= 90 THEN
    OUTPUT "Pass with merit"
ENDIF

Pass with merit requires: (high score OR high coursework) AND good attendance.

Brackets matter! The condition "A AND B OR C" is ambiguous. It could mean "(A AND B) OR C" or "A AND (B OR C)" which give different results. Always use brackets to make your intention clear.
Brackets Change the Result

Let A = FALSE, B = FALSE, C = TRUE

(A AND B) OR C = (FALSE AND FALSE) OR TRUE = FALSE OR TRUE = TRUE

A AND (B OR C) = FALSE AND (FALSE OR TRUE) = FALSE AND TRUE = FALSE

Same values, different result - brackets matter!

📐 De Morgan's Laws

De Morgan's Laws allow you to simplify complex Boolean expressions by "distributing" NOT over AND/OR. They state that the opposite of an AND expression is an OR expression of the opposites, and vice versa.
De Morgan's Laws:
NOT (A AND B) = (NOT A) OR (NOT B)
NOT (A OR B) = (NOT A) AND (NOT B)

When you push NOT through AND, it becomes OR (and vice versa).
Each individual condition is also negated.
De Morgan's Law Example 1

Original: NOT (age >= 18 AND hasID = TRUE)

This means: it is NOT the case that both age >= 18 AND has ID.

Applying De Morgan's: (age < 18) OR (hasID = FALSE)

This means: either too young OR no ID - same meaning, simpler expression!

De Morgan's Law Example 2

Original: NOT (raining = TRUE OR snowing = TRUE)

This means: it is NOT the case that it is raining OR snowing.

Applying De Morgan's: (raining = FALSE) AND (snowing = FALSE)

This means: it is not raining AND it is not snowing - same meaning!

Original Expression De Morgan Equivalent English Meaning
NOT (x > 0 AND x < 100) x <= 0 OR x >= 100 x is outside the range 0-100
NOT (a = TRUE OR b = TRUE) a = FALSE AND b = FALSE Both a and b are false
NOT (age >= 18 AND hasPassport) age < 18 OR NOT hasPassport Either too young or no passport

📊 Operator Precedence

Boolean operators have an order of precedence: NOT is evaluated first, then AND, then OR. Use brackets to override this order.
Full Precedence (highest to lowest):
1. Brackets ()
2. NOT
3. AND
4. OR

So "NOT A OR B AND C" means "(NOT A) OR (B AND C)"
Precedence Example
NOT TRUE OR TRUE AND FALSE

Step 1: NOT TRUE = FALSE

Step 2: TRUE AND FALSE = FALSE

Step 3: FALSE OR FALSE = FALSE

⚠️ Common Mistakes

Mistake Why It's Wrong How to Fix It
Using AND when you mean OR "age < 13 AND age > 19" is always FALSE Use OR: "age < 13 OR age > 19"
Forgetting brackets with mixed operators A AND B OR C is ambiguous Write (A AND B) OR C explicitly
NOT (A AND B) = NOT A AND NOT B This is WRONG - De Morgan says OR, not AND NOT (A AND B) = NOT A OR NOT B
Double negation confusion NOT NOT TRUE = TRUE, but it's confusing Simplify: remove double NOTs

❓ Practice Questions

Q1: Complete the truth table for A AND B where A = TRUE, B = FALSE.

Q2: Evaluate: NOT (TRUE OR FALSE)

Q3: Use De Morgan's Laws to simplify: NOT (x >= 0 AND x <= 100)

Q4: Write a condition that checks if a person is eligible for a student discount (age < 18 OR hasStudentCard = TRUE) AND isShopping = TRUE.

Q5: Evaluate step by step: NOT FALSE AND TRUE OR FALSE

✅ Answers

  1. TRUE AND FALSE = FALSE. Both must be TRUE for AND to return TRUE.
  2. TRUE OR FALSE = TRUE. Then NOT TRUE = FALSE.
  3. Using De Morgan's: NOT(x >= 0) OR NOT(x <= 100) = x < 0 OR x > 100.
  4. IF (age < 18 OR hasStudentCard = TRUE) AND isShopping = TRUE THEN
        OUTPUT "Student discount applied"
    ENDIF
  5. Step 1: NOT FALSE = TRUE (NOT has highest precedence). Step 2: TRUE AND TRUE = TRUE (AND next). Step 3: TRUE OR FALSE = TRUE (OR lowest). Result: TRUE.

🎯 Exam Tips

⚠️ Common Errors

✗ Thinking AND and OR are interchangeable ✓ AND requires ALL conditions to be true; OR requires at least ONE condition to be true. They produce different results and are not interchangeable.

✗ Forgetting that NOT reverses a Boolean value ✓ NOT TRUE = FALSE and NOT FALSE = TRUE. NOT flips the result — it is used to negate conditions, e.g. WHILE NOT finished.

✗ Assuming AND is evaluated before OR without brackets ✓ AND has higher precedence than OR in most languages. Use brackets to make intent clear: (A OR B) AND C is different from A OR (B AND C).

✗ Confusing NOT with negative numbers or minus signs ✓ NOT is a logical operator that reverses True/False. It is not the same as the arithmetic minus sign. NOT(5 > 3) = FALSE, not -5.

✍️ Model Answer

Full-Mark Response

A login system requires a username of at least 5 characters AND a password of at least 8 characters. The user is locked out after 3 failed attempts. Write pseudo-code using Boolean operators to implement this. [5 marks]

attempts ← 0 loggedin ← FALSE WHILE attempts < 3 AND loggedin = FALSE INPUT 'Username: ', username INPUT 'Password: ', password IF LENGTH(username) >= 5 AND LENGTH(password) >= 8 THEN OUTPUT 'Login successful' loggedin ← TRUE ELSE attempts ← attempts + 1 IF NOT loggedin AND attempts < 3 THEN OUTPUT 'Invalid credentials, try again' ENDIF ENDIF ENDWHILE IF NOT loggedin THEN OUTPUT 'Account locked: too many attempts' ENDIF

📊 AO Deep Dive

Assessment Objective Analysis

AO1 (Computational Thinking — 40%): Demonstrate knowledge and understanding of the principles and concepts of computer science, including Boolean operations: AND, OR and NOT for AQA 8525, OCR J277 & Edexcel 1CP2.

AO2 (Application — 40%): Apply knowledge and understanding of computer science, including Boolean operations: AND, OR and NOT to analyse problems in computational terms and to design, write and evaluate solutions.

AO3 (Evaluation — 20%): Evaluate the effectiveness, correctness and efficiency of computational solutions, including Boolean operations: AND, OR and NOT, and make reasoned judgements about trade-offs.

📝 Exam Technique

GCSE Computer Science Exam Tips:
AND needs ALL conditions True, OR needs ANY condition True, NOT reverses. Use brackets to make complex conditions clear. Build truth tables if asked to evaluate Boolean expressions. For validation, AND is used when ALL criteria must be met; OR when ANY criterion is sufficient. Remember AND has higher precedence than OR — use brackets to override.

📝 Exam Questions by Topic

🎬 Video Resources

Share this page

Ready to ace your GCSE Computer Science exams?

Get the best revision books and guides to boost your grades.