GCSE · Computer Science · Edexcel · Spec 1CP2
Logical operator NOT
Is the ten of spades a heart? False. Is it not a heart? True. One small word just flipped the answer. Here is how.
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 each Next, predict: 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"? No, it is spades, so A is False. Now not reverses that one result: 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 parts of three expressions: age > 12 and age < 60, value > 7 or suit == "spades", and not (suit == "hearts"). Is each highlighted 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. A logical operator works on the True/False results those comparisons give.
Logical operator (0)
Combines or reverses True/False results
Where the line is: A logical operator never compares values itself. It takes True/False results and combines or reverses them.
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, otherwise run the else branch. Pick a card and follow the route.
Card drawn
A True condition runs the if branch. A False condition runs the else branch.
3 possible routes.
A selection 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
- A logical expression always ends up as True or False, and the three basic logical operators are and, or and not.
- Relational operators compare values. Logical operators then combine or reverse those True/False results into a single value.
- You can build bigger expressions, like age > 12 and age < 60, and the whole thing still returns just one True or False.
- The odd one out is not: it acts on a single expression, whereas and and or each combine two.
Have a goThree logical operators: and, or, not. Which one is the odd one out, and what makes it odd?
not. It acts on a single expression.
and and or each need two expressions to combine, so not is the only one of the three with a single input.
- What not does is reverse the result. If the comparison is True, not gives False, and if it is False, not gives True.
- So the truth table for not A has two rows: not True gives False, and not False gives True.
Have a goYour friend Sam says, "I know this one: not always gives False." Use the truth table to catch Sam out. What is not False?
True
not reverses its input, so a False input gives True. Sam only has half of the truth table.
- Work from the inside out: evaluate the comparison first, then apply not to the True or False it gave you.
Have a goA card has the value 9 and the test is not (value > 7). Comparison first. What is the final answer?
False
9 > 7 is True, and not reverses True to False. Stopping at the comparison would give True, which skips the flip.
- Card check: for the ten of spades, suit != "hearts" returns True, because the suit is spades, not hearts.
- In a selection statement, a True condition runs the if branch and a False condition runs the else branch.
The big picture
The not operator 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. Work out the comparison first, then flip it. That one flip can send a selection statement down the other branch.
Key points
Worked example
Problem
A program contains: if not (suit == "spades") then run the if branch, otherwise run the else branch. Which branch runs for the queen of diamonds? And for the jack of spades?
⚠ Watch out
Applying not before you have an answer to flip. not works on the True or False that the comparison gives, so work that out first. Skip it and there is nothing for not to reverse.
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
(13)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?
Which part of age > 12 and age < 60 is the logical operator?
In a selection 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 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.