GCSE · Computer Science · Edexcel · Spec 1CP2
Logical operator NOT
Is the ten of spades a heart? False. Is it not a heart? True. Same card, one tiny word, opposite answer. Let's see how that works.
Computer Science · Logical expressions
Same card, two questions
Ask a yes/no question about the card. Then ask not, which turns that answer round.
Let A be the question suit == "hearts". Step through two cards. Before you press Next, guess: what will not A be?
| Card | A: suit == "hearts" | not A |
|---|---|---|
| ten of spades | False | True |
| ace of hearts | True | False |
Output
Step 1: Ten of spades. Comparison first: is the suit "hearts"? Nope, it's spades, so A is False. Now not gets to work on that one result and reverses it: not False is True.
Step through the trace — every value is the lesson’s, not run by the page.
Computer Science · Operators
Compare, or combine?
Here are pieces from four expressions: age > 12 and age < 60, value > 7 or suit == "spades", suit != "hearts", and not (suit == "hearts"). Is each piece a relational operator or a logical operator?
Still to sort
Relational operator (0)
Compares values
Where the line is: A relational operator compares values and gives a True/False result. A logical operator works on those True/False results.
Logical operator (0)
Combines or reverses True/False results
Where the line is: A logical operator never compares values itself. and and or combine two True/False results into one; not reverses a single result.
not lives in a family of operators. Which job does each piece do?
Predict, then check
Comparison first. Flip second.
A card has the value 3. What does not (value > 7) give?
Computer Science · Selection
Which way does the program go?
The program checks: if not (suit == "hearts") run the if branch, else run the else branch. Pick a card and follow its route.
Card drawn
A True condition runs the if branch. A False condition runs the else branch.
3 possible routes.
An if/else statement follows exactly one route. The condition decides which.
WHAT YOU'VE LEARNED
A quick recap of today's lesson.
One expression in. One reversed answer out.
What you need to know
- Every logical expression ends up as one of two values, True or False. The three basic logical operators are and, or and not.
- Relational operators such as >, == and != compare values. Logical operators then combine or reverse those True/False results into one value.
- Bigger expressions, like age > 12 and age < 60, still boil down to just one True or False for the whole thing.
Have a goYour mate reckons age > 12 and age < 60 hands back two answers, one for each comparison. For age 30, how many results does the whole expression give?
Just one: a single True or False.
The logical operator and combines the two comparison results into one value, so the whole expression never returns two separate answers.
- Here's the odd one out: not acts on a single expression, whereas and and or each combine two.
- not's whole job is reversing. If the expression is True, not gives False; if it's False, not gives True.
- So the truth table for not A is only two rows: not True is False, and not False is True.
Have a goSam's homework reads: not ___ = True. Sam has left the gap empty, muttering "but not only ever gives False". What goes in the gap?
False
not reverses its input, so the input that comes out True is False. Sam has only learned the top row of the truth table.
- Order matters. Work out the comparison inside the brackets first, then let not flip the True or False it gave you.
Have a goA card has the value 9 and the test is not (value > 7). Comparison first, then the flip. What's the final answer?
False
9 > 7 is True, and not reverses True to False. Stopping at the comparison would give True, which forgets the flip.
- Card check: for the ten of spades, suit != "hearts" returns True, because the suit is spades, not hearts.
- In an if/else selection statement, a True condition runs the if branch and a False condition runs the else branch.
The big picture
not is a logical operator that acts on a single expression and reverses its True or False result: not True is False, and not False is True. Do the comparison first, then flip it. In an if/else statement, that one flip can send the program down the other branch.
Key points
Worked example
Problem
A program contains: if not (suit == "spades") run the if branch, else run the else branch. Which branch runs for the queen of diamonds? And for the jack of spades?
⚠ Watch out
Writing down an answer before the comparison is done, usually False, because "not" sounds negative. not has nothing to flip until the expression inside the brackets has given True or False. Work that out first, then reverse it.
Memory hook
Compare first, flip second. not never picks an answer; it only turns the answer round.
Check yourself
Your friend says not (suit == "hearts") is False for the ten of spades. Which step did they skip, and what is the real answer?
Flashcards
(14)What are the three basic logical operators?
What does a logical expression evaluate to?
How do relational operators and logical operators differ?
How many expressions does not act on? And what about and and or?
What does the not operator do to a result?
Complete the truth table for not A.
When is a not-expression True?
In not (value > 7), what do you work out first?
The ten of spades is drawn. What does suit != "hearts" return, and why?
Is != a relational operator or a logical operator?
Which part of age > 12 and age < 60 is the logical operator?
In an if/else statement, which branch runs for a True condition? For a False one?
How can adding not change which branch a program takes?
A friend says "not makes an expression False". Are they right?
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.