GCSE · Computer Science · AQA · Spec 8525

OR (Boolean operator in code)

"Tea or coffee?" Say "both" and people look at you funny. Code is more generous. In code, OR is happy with either one, and it's happy with both.

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 sit in both circles, or in neither. Then check: which days get the reminder?

  • 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. Before each step, guess what the whole OR will be, then watch each part get 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 whole centimetres. 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 one bigger condition, and the result is always just True or False.
  • A OR B is True when A is True, when B is True, or when both are True.
  • The only way to get False is for A and B to be False together.
  • Careful: everyday 'or' often means one but not both. Code OR happily includes both.
  • Have a goYour friend insists IF hungry OR bored THEN OUTPUT "Snack time" stays silent on a day they're hungry AND bored. Snack or no snack?

    Snack time. The message is output.

    Both parts True still makes OR True. Your friend is using everyday 'one but not both', which code OR doesn't follow.

  • In an IF statement, the THEN branch runs whenever the OR condition is True.
  • In a WHILE loop, the loop repeats while the OR is True, so it stops only when every part is False.
  • Have a goA game runs WHILE lives > 0 OR shield = True. Lives drop to 0, but shield is still True. Does the loop go round again?

    Yes, it repeats.

    shield = True keeps the OR True. Losing the last life only makes one part False, and the loop needs both parts False to stop.

  • Write each side as a full comparison: choice = 1 OR choice = 2, never choice = 1 OR 2.
  • Have a goWhat's wrong with IF colour = "red" OR "blue" THEN? Rewrite it so it does what the programmer meant.

    IF colour = "red" OR colour = "blue" THEN

    The right side, "blue", isn't compared with anything, so it isn't a full condition. colour has to appear on both sides.

  • Test the edge values: 10 < 10 is False, because 10 isn't less than itself.
  • Mixing OR with AND or NOT? Brackets decide which parts are combined first, and moving them can change the answer.
  • NOT (A OR B) works out the bracket first, then flips it, so it's True only when A and B are both False.

The big picture

OR joins two conditions into one that is True if at least one part is True, and that includes when both parts are True. It is False only when both parts are False. You'll use it to steer IF statements and WHILE loops, and when you mix it with AND or NOT, brackets decide which parts go together.

Key points

1Code OR includes the both-True case, unlike the everyday 'one but not both'.
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. It reads fine in English, but the 2 isn't compared with anything, so it doesn't test what you meant. Each side of OR needs to be a complete condition that is True or False on its own: 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)
Name the three ways A OR B can come out True.
A is True, B is True, or both are True.
What is the one way A OR B can come out False?
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 isn't a complete condition. Write answer = "y" OR answer = "Y".
How do you work out NOT (a OR b)?
Work out a OR b first, then flip it. So it's True in just one case: when a and b are both False.
Why do brackets matter in (a OR b) AND c?
They decide which parts are combined first. Move them and the result can change.

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 26 October 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.