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.

Who gets the coat reminder?

One True part is enough. Two is fine too.

A weather app runs: IF raining OR temperature < 10 THEN OUTPUT "Take a coat". For each day, tick which parts of the condition are True. A day can go in both circles, or in neither.

  • A raining is True
  • B temperature < 10 is True
  1. Monday: raining, 15 °C
  2. Tuesday: dry, 4 °C
  3. Wednesday: raining, 6 °C
  4. Thursday: dry, 18 °C
  5. Friday: dry, 10 °C
  6. Saturday: raining, 10 °C
  7. Sunday: dry, -2 °C

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.

1choice ← USERINPUT
2WHILE choice < 1 OR choice > 3
3 OUTPUT "Choose 1, 2 or 3"
4 choice ← USERINPUT
5ENDWHILE
6OUTPUT "Thank you"
choice
choice < 1
choice > 3
whole OR
Output
Press Start to run the first line.
·

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)?

Your turn

Write the condition

A theme-park ride turns riders away if they are shorter than 120 cm or taller than 195 cm. The variable height holds a rider's height in cm. Write pseudocode that uses OR to output "Sorry, you cannot ride" for these riders and "Enjoy the ride" for everyone else. [4 marks]

0 words · your answer stays on this page and is not sent anywhere.

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

1Everyday 'or' often means one but not both. In code, OR includes the both-True case.
2Each side of OR must be a complete condition, such as choice = 1 OR choice = 2.
3A WHILE loop with an OR condition stops only when every part is False.
4NOT (A OR B) is True only when A and B are both False.
5Test the edge values: 10 < 10 is False.

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 A is True, when B is True, or when both are True.
When is A OR B False?
Only when A and B are both False.
How is 'or' in code different from 'or' in everyday speech?
Everyday 'or' often means one but not both. Code OR is also True when both parts are True.
How long does WHILE a OR b keep looping?
For as long as at least one part is True. It stops only when both parts are False.
What is wrong with IF answer = "y" OR "Y"?
The right-hand side is not a complete condition. Write answer = "y" OR answer = "Y".
How does NOT (a OR b) work?
Work out a OR b first, then flip it. So it is True in just one case: the case where a OR b is False.
Why do brackets matter in (a OR b) AND c?
They decide which parts are combined first. Moving them can change the result.

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 posted

More AQA GCSE Computer Science topics

See the full AQA Computer Science curriculum →

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.