GCSE · Computer Science · AQA · Spec 8525
OR (Boolean operator in code)
"Tea or coffee?" Say "both" and people stare. In code, OR is more generous: either part being True is enough, and both being True counts too.
Computer Science · Algorithms
Trace table — dry run the code
A menu only accepts 1, 2 or 3. The user types 0, then 7, then 2. Watch each part of the WHILE condition, and the whole OR, every time it is checked.
Ready when you are — step through one line at a time.
Predict, then check
Same values, same operators. Only the brackets have moved.
weekend ← True, holiday ← False, raining ← False. Which of these is True: (1) (weekend OR holiday) AND raining, or (2) weekend OR (holiday AND raining)?
WHAT YOU'VE LEARNED
A quick recap of today's lesson.
…and two Trues still count.
What you need to know
- OR joins two conditions into a single condition that is either True or False.
- A OR B is True when A is True, when B is True, or when both are True.
- A OR B is False only when A and B are both False.
- In an IF statement, the THEN branch runs when the OR condition is True. In a WHILE loop, the loop repeats while it is True.
- When OR is combined with AND or NOT, brackets decide which parts go together.
The big picture
OR joins two conditions into one that is True if at least one part is True, including when both are. It is False only when both parts are False. You use it to control IF statements and WHILE loops, and brackets decide how it combines with AND and NOT.
Key points
Worked example
Problem
A game keeps running until the player has 0 lives or the timer goes over 60 seconds. Write the WHILE condition that keeps the game going, then check what happens when lives = 2 and time = 61.
⚠ Watch out
Writing choice = 1 OR 2. Each side of OR has to be a complete condition that is True or False on its own, so write choice = 1 OR choice = 2.
Memory hook
OR is generous: one True is enough, and two Trues are fine. The only way to fail an OR is to fail both parts.
Check yourself
If x ← 7, is x < 5 OR x > 5 True? And if x ← 5? (7: True, since 7 > 5. 5: False, since both parts fail.)
Flashcards
(7)When is A OR B True?
When is A OR B False?
How is 'or' in code different from 'or' in everyday speech?
How long does WHILE a OR b keep looping?
What is wrong with IF answer = "y" OR "Y"?
How does NOT (a OR b) work?
Why do brackets matter in (a OR b) AND c?
Tap any card to flip it, or use Study as deck to go through them one at a time. In the full lesson these run as a spaced-repetition deck — you rate each card Hard, Good or Easy and the tricky ones keep coming back until they stick.
Learning with Lightbulb is opening soon
You can use this lesson now. Join the waitlist and we'll let you know when the full Lightbulb experience is ready.
Keep me postedMore AQA GCSE Computer Science topics
How this lesson was checked. This AQA GCSE Computer Science (specification 8525)lesson was published through Lightbulb Learning's human-designed editorial process — the educational standards, accuracy rules and publication checks it must pass were authored and approved by Philip Halpin. It passed subject-specific assessment, automated educational checks and technical publication verification before going live (publication checks completed 30 September 2026). Published pages are monitored, human spot-checking is ongoing across the lesson library, and anything found wrong is corrected or withdrawn. How our lessons are made and checked. Spotted a mistake? Email hello@lightbulblearning.co and we'll review it.