GCSE · Computer Science · Edexcel · Spec 1CP2
Logical operator OR
Rule: a card matches if it's over 7 or a spade. The 10 of spades is both. Still a match? Your gut might wobble. Your program won't.
Computer Science · Truth tables
The whole truth about or
Call the two conditions A and B. There are only four ways they can turn out. Predict each result before it appears.
Before each row appears, say the result of A or B out loud.
| A | B | A or B |
|---|---|---|
| True | True | True |
| True | False | True |
| False | True | True |
| False | False | False |
Output
Step 1: Both True, and the result is still True. If 'one or the other, not both' popped into your head, this row is the one that settles it.
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 whether the card meets each condition, the or result, and whether anything is printed.
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 your program can answer with True or False, like value > 7.
- There are three basic logical operators: and, or, and not. Today is all about or.
- or joins conditions built with relational operators, like > and ==, into one logical expression with a single True or False result.
- An or expression is True when either condition is True, or when both are.
Have a goThe 9 of spades turns up at a club whose rule is value > 7 or suit == "spades". The bouncer frowns: "Both? Sorry, I only take one OR the other." Is he right?
No. The 9 of spades gets in.
Both conditions are True, and or is True when either or both are. The bouncer is using a 'pick one' rule that or doesn't follow.
- There's exactly one way to get False: both conditions 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. One False doesn't sink an or: you only get False when both are False.
- Here's the trap: it's easy to read or as 'one or the other, not both'. In a program, or still gives True when both are True.
- A truth table lists every True/False pairing with its result. Two conditions means four rows, and only one is False.
- To evaluate by hand, decide whether each condition is True or False, then apply the or rule.
- In an if statement, a True expression runs the branch and a False one skips it.
Have a goHere's if score < 0 or score > 100: print("Invalid score"). Does anything get printed 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.
- Check with the card example: the nine of diamonds matches value == 9 or suit == "hearts" because the value is 9, even though the suit is not hearts.
The big picture
or is one of the three basic logical operators, alongside and and not. It joins two conditions into one logical expression that is True when either condition is True, or when both are, and False only when both are False. A truth table shows that in four rows. Put an or expression in an if statement and a True result runs the branch, while a False result skips it.
Key points
Worked example
Problem
A weather app contains: if raining == True or temperature < 5: print("Take a coat"). On Monday raining is False and the temperature is 3. On Tuesday raining is False and the temperature is 8. Does the app print "Take a coat" on each day?
⚠ Watch out
Reading or as 'one or the other, not both' and calling True or True False. A close cousin is saying the expression is False because one condition is False. With or, the only route to False is both conditions False.
Memory hook
Or is generous: one True gets you in, two Trues still get you in, and only False with False gets turned away.
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
(14)What is a condition in a program?
Name the three basic logical operators.
What does a logical expression combine?
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?
What is a common wrong idea about or?
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?
Ten of spades: what does if value > 7 or suit == "spades": print("My card is a match") do?
Why is 'one condition is False, so the or expression is False' a slip?
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 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.