SLIDE 1 / 10
CSZone.co.uk
Click anywhere to advance · Arrow keys also work
AQA 7517 · Paper 1 · 4.1.1c

Boolean Logic &
Boolean Operators

AQA A-Level Computer Science · Section 4.1 Fundamentals of Programming

WHAT YOU'LL LEARN
AND · OR · NOT operators · Truth tables · Boolean expressions in programs
AQA SPEC LINK
4.1.1 — Use of Boolean operators in conditional statements & loops
Boolean Data Type

Boolean: True or False

A Boolean value can only be True or False. Boolean expressions use AND, OR, NOT to combine comparisons.
AND
True only if both operands are True
OR
True if at least one operand is True
NOT
Inverts the Boolean value
AND Operator

AND — Truth Table

ABA AND B
TrueTrueTrue
TrueFalseFalse
FalseTrueFalse
FalseFalseFalse
MNEMONIC
AND = "both must be true"
Like a security door needing BOTH a key AND a PIN code.
IN PSEUDOCODE
IF age ≥ 18 AND hasID = True THEN
OR Operator

OR — Truth Table

ABA OR B
TrueTrueTrue
TrueFalseTrue
FalseTrueTrue
FalseFalseFalse
MNEMONIC
OR = "at least one must be true"
Only False if BOTH are False.
IN PSEUDOCODE
IF grade = 'A' OR grade = 'B' THEN
NOT Operator

NOT — Inverting a Boolean

ANOT A
TrueFalse
FalseTrue
USE CASES
IF NOT gameOver THEN ...
WHILE NOT found DO ...
IF NOT (x = y) THEN ...
NOT has highest precedence among boolean operators: NOT is evaluated first, then AND, then OR. Use brackets to clarify complex expressions.
Compound Conditions

Combining Boolean Operators

AQA EXAMPLE — Fairground Ride
height ← INT(USERINPUT)
age ← INT(USERINPUT)
IF (height ≥ 120 AND age ≥ 12) OR hasWristband = True THEN
   OUTPUT "Welcome aboard!"
ELSE
   OUTPUT "Not eligible"
ENDIF
⚠️ Always use brackets to make compound conditions unambiguous in the exam. AQA examiners appreciate clear structure.
Precedence

Boolean Operator Precedence

Order of evaluation (highest → lowest):
1st: NOT — evaluated first
2nd: AND
3rd: OR — evaluated last
AMBIGUOUS — AVOID
A OR B AND NOT C
Evaluates as: A OR (B AND (NOT C))
CLEARER — PREFERRED
A OR (B AND (NOT C))
Brackets make intent explicit
Application

Boolean Operators in Loops

VALIDATION LOOP EXAMPLE
score ← INT(USERINPUT)
WHILE score < 0 OR score > 100
   OUTPUT "Enter a score between 0 and 100"
   score ← INT(USERINPUT)
ENDWHILE
OUTPUT "Score accepted: " + STR(score)
The WHILE condition uses OR to keep looping while the input is invalid (too low OR too high). The loop exits when both conditions are False.
AQA Exam Style

Practice Question

AQA 7517 — Paper 1 Style Question
Complete the truth table for the expression: NOT A AND (B OR C)
[4 marks]
ABCNOT AB OR CResult
TTFFTFalse
TFFFFFalse
FTFTTTrue
FFFTFFalse
Summary

Key Points to Remember

AND — True only if BOTH operands are True
OR — True if AT LEAST ONE operand is True (False only if both are False)
NOT — Inverts the Boolean; NOT True = False, NOT False = True
Precedence: NOT → AND → OR — use brackets to be safe
Boolean operators are used in IF conditions and WHILE loops to control flow
🎉 Lesson complete — move to the quiz!