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 · Logical operators

Which cards get through?

The rule is value > 7 or suit == "spades". For each card, tick every condition it meets, or neither. Watch where it lands, then check.

  • A value > 7
  • B suit == "spades"
  1. 10 of spades
  2. 10 of hearts
  3. 5 of spades
  4. 3 of clubs
  5. 8 of spades
  6. 8 of diamonds
  7. 2 of spades
  8. 7 of hearts

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 or Bgate
ABA or B
TrueTrueTrue
TrueFalseTrue
FalseTrueTrue
FalseFalseFalse
A=True, B=True → A or B = True

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.

1 / 4

Step through the trace — every value is the lesson’s, not run by the page.

Step 1 of 4: 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..

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.

1read the value and suit of the next card
2if value > 7 or suit == "spades":
3 print("My card is a match")
value
suit
value > 7
suit == "spades"
or
Output
Press Start to run the first line.
·

Ready when you are — step through one line at a time.

Computer Science · Logical operators

What do you think or does?

An if statement joins two conditions with or.

Be honest: which of these is closest to what you think right now?
How sure are you?

Computer Science · Logical operators

Find the faulty line

A student evaluates value == 9 or suit == "hearts" for the nine of diamonds. Which line goes wrong?

A student's answer — which line goes wrong?

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

1An or expression is True when either condition is True, or when both are True.
2It is False only when both conditions are False. A two-condition truth table has four rows, and just one gives False.
3In an if statement the branch runs when the whole expression is True and is skipped when it is False.
4In a program, or includes the both-True case, so True or True is True.

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?
Something a program can answer with True or False, such as value > 7.
Name the three basic logical operators.
and, or, not.
What does a logical expression combine?
Relational operators (like > and ==) and logical operators, giving a single True or False.
When is an or expression True?
When either condition is True, or when both are True.
When is an or expression False?
Only when both conditions are False.
True or True: what is the result?
True. Both True still counts.
False or True: what is the result?
True. One True is enough, whichever side it is on.
What is a common wrong idea about or?
That it means 'one or the other, not both', so True or True is False. In a program, both True still gives True.
What is a truth table?
A list of every True/False pairing of the conditions, with the result of the expression for each.
For two conditions, how many truth table rows are there, and how many give False for or?
Four rows. Only one gives False: False with False.
In the two-circle picture, where is an or expression False?
Only for items outside both circles.
What happens to an if branch when its or expression is False?
The branch is skipped and its statements do not run.
Ten of spades: what does if value > 7 or suit == "spades": print("My card is a match") do?
The expression is True, so the branch runs and "My card is a match" is displayed.
Why is 'one condition is False, so the or expression is False' a slip?
An or expression is False only when both conditions are False. With or, one True is enough.

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 Edexcel GCSE Computer Science topics

See the full Edexcel Computer Science curriculum →

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.