GCSE · Computer Science · Edexcel · Spec 1CP2
Logical operator AND
The five of hearts is a heart, but it is not the king. Does it pass the check "king and hearts"? Four routes, and only one gets through.
Computer Science · and
Four routes, one way through
Pick a value for A, then a value for B. Reveal where the route ends.
The two conditions → Condition A → Condition B
4 routes.
Two conditions, A and B, each True or False. Walk every route and see what A and B ends up as.
Computer Science · Algorithms
Trace table — dry run the code
Step through the program one line at a time. Watch each condition get its own True or False, then watch and join them.
Ready when you are — step through one line at a time.
WHAT YOU'VE LEARNED
A quick recap of today's lesson.
Four routes. Only one way through.
What you need to know
- A logical expression always works out to True or False.
- The three basic logical operators are and, or and not. This lesson is all about and.
- Logical operators join relational comparisons, like age > 12, so several checks boil down to one True or False.
- With and, both conditions must be True. If either one is False, the whole expression is False.
Have a goSam says: "True and False is True. Well, one of them is True, and that counts!" Is Sam right?
No. True and False is False.
With and, both conditions must be True, so one True is not enough. Sam is thinking of a different operator.
- Only True and True gives True. True and False, False and True, and False and False all give False.
- Five of hearts: value == "king" and suit == "hearts" is False. The suit matches, but the value is not king.
Have a goNow try the king of hearts. What does value == "king" and suit == "hearts" give?
True.
The value is king and the suit is hearts. Both conditions are True, so the whole expression is True.
- Range check: age > 12 and age < 60 is True only when age is above 12 and also below 60.
Have a goage is 8. Which condition in age > 12 and age < 60 fails, and what is the result?
age > 12 fails. The result is False.
8 > 12 is False. It does not matter that 8 < 60 is True, because one False sinks the whole expression.
- To meet a requirement, write one comparison per condition and join them: value <= 10 and suit == "hearts".
- Inside an if statement, a False and expression sends the program to the else branch.
The big picture
A logical expression always works out to True or False. With and, the whole expression is True only when both conditions are True. One False anywhere and the whole thing is False. That is how programs decide which branch of an if statement to run.
Key points
Worked example
Problem
A game gives a bonus when score > 50 and lives == 3. A player has a score of 80 and 2 lives. Is the bonus given?
⚠ Watch out
Reading and as "one match is enough". That is the rule for or. With and, the five of hearts fails value == "king" and suit == "hearts" because the value is not king, even though the suit matches.
Memory hook
Think of and as a door with two locks. Both keys must turn. One missing key and the door stays shut.
Check yourself
Without looking back: a program checks two conditions joined with and. The first is True and the second is False. What does the whole expression give, and why is one False enough to decide it?
Flashcards
(12)What can a logical expression evaluate to?
Name the three basic logical operators.
What does a logical expression combine?
When is A and B True?
One condition in an and expression is False. What is the whole expression?
False and False gives...?
There are four combinations of two conditions. How many give True with and?
Five of hearts: what does value == "king" and suit == "hearts" give?
Five of hearts: what does value == 5 and suit == "hearts" give?
How do you write "age is above 12 and also below 60"?
How do you check for a value less than or equal to 10 and the suit hearts?
An if statement uses an and expression that works out False. Which branch runs?
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.