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

Which cards get through?

A program checks each card with this rule: value > 7 or suit == "spades". For each card, tick every condition it meets. Tick neither if it meets neither. Then check.

  • A value > 7
  • B suit == "spades"
  1. 9 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. Step through every True/False pairing and watch the result.

Before each row appears, predict the result of A or B.

A or Bgate
ABA or B
TrueTrueTrue
TrueFalseTrue
FalseTrueTrue
FalseFalseFalse
A=True, B=True → A or B = True

Output

 

Step 1: Both True. The result is still True. This is the row that everyday 'or' gets wrong.

1 / 4

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

Step 1 of 4: Both True. The result is still True. This is the row that everyday 'or' gets wrong..

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.

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.

Which statement about or do you agree with most 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 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

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 one gives False.
3In an if statement the branch runs when the whole expression is True and is skipped when it is False.
4or is not 'one or the other but not both', and it does not follow the rule for and.

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?
Something a program can answer with True or False, such as value > 7.
What does or do to two conditions?
It joins them into one logical expression, which is itself 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.
How does everyday 'or' differ from or in a program?
Everyday 'or' often means one or the other, not both. 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.
What is the slip of treating or like and?
Saying the result is False because one condition is 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 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.