GCSE · Computer Science · Edexcel · Spec 1CP2
Logical operator OR
A club's rule: value over 7 or a spade. The 9 of spades meets both. Does the bouncer turn it away? Your program won't.
Computer Science · Truth tables
The whole truth about or
Call the two conditions A and B. Step through every True/False pairing and watch the result.
Before each row appears, predict the result of A or B.
| A | B | A or B |
|---|---|---|
| True | True | True |
| True | False | True |
| False | True | True |
| False | False | False |
Output
Step 1: Both True. The result is still True. This is the row that everyday 'or' gets wrong.
Step through the trace — every value is the lesson’s, not run by the page.
Computer Science · Algorithms
Trace table — dry run the code
Dry-run the same rule on four cards. Each row records the two conditions, the or result, and whether the branch printed anything.
Ready when you are — step through one line at a time.
WHAT YOU'VE LEARNED
A quick recap of today's lesson.
What you need to know
- A condition is a question a program can answer with True or False, like value > 7.
- or joins two conditions into one logical expression, and that expression is also True or False.
- An or expression is True when either condition is True, or when both are True.
Have a goThe 8 of spades reaches a club with the rule value > 7 or suit == "spades". The bouncer says: "Both? Sorry, I only take one OR the other." Is he right?
No. The 8 of spades gets in.
Both conditions are True, and an or expression is True when either or both are, so being in both circles still counts.
- It is False only when both conditions are False.
Have a goSay it before you reveal it: x is 4. Is x > 10 or x < 5 True or False?
True.
x > 10 is False, but x < 5 is True, and one True condition is enough.
- Everyday English often hears 'or' as 'one or the other, not both'. In programming, it does not.
- A truth table lists every True/False pairing of the conditions with the result. For two conditions that is four rows, and only one gives False.
- In a selection statement, the branch runs when the whole expression is True and is skipped when it is False.
Have a goHere is if score < 0 or score > 100: print("Invalid score"). Does it print anything when score is 55?
No. Nothing is printed.
55 < 0 is False and 55 > 100 is False, so the or expression is False and the branch is skipped.
- To evaluate, work out each condition on its own first, then combine the results with or.
- and is a different logical operator, so do not use its rule for or.
The big picture
An or expression joins two conditions and is True when either condition is True, or when both are. It is False only when both are False, which a truth table shows in four rows. In a selection statement, a True expression runs the branch and a False one skips it.
Key points
Worked example
Problem
A weather app contains: if raining == True or temperature < 5: print("Take a coat"). Today raining is True and the temperature is 3. Does the app print "Take a coat"?
⚠ Watch out
Hearing 'or' the everyday way, as 'one or the other, not both', and marking True or True as False. Its close cousin is using the rule for and, where one False spoils everything. With or, the only way to get False is both conditions False.
Memory hook
Or is generous: one True is enough, both True still counts, and only False with False says no.
Check yourself
Write the four rows of the truth table for A or B, circle the only False row, then say why 'one or the other, not both' is the wrong reading.
Flashcards
(12)What is a condition in a program?
What does or do to two conditions?
When is an or expression True?
When is an or expression False?
True or True: what is the result?
False or True: what is the result?
How does everyday 'or' differ from or in a program?
What is a truth table?
For two conditions, how many truth table rows are there, and how many give False for or?
In the two-circle picture, where is an or expression False?
What happens to an if branch when its or expression is False?
What is the slip of treating or like and?
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 Edexcel GCSE Computer Science topics
How this lesson was checked. This Edexcel GCSE Computer Science (specification 1CP2)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 9 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.