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?

CardA: suit == "hearts"not A
ten of spadesFalseTrue
ace of heartsTrueFalse
Card=ten of spades, A: suit == "hearts"=False → not A = True

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.

1 / 2

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

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

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.

6 of 6 still to sort.

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.

On if not (suit == "hearts"). 3 branches to choose from.

A selection statement follows exactly one route. The condition decides which.

Computer Science · not

What does not really do?

A program contains the condition not (suit == "hearts").

Which of these is closest to what you think not does?
How sure are you?

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

1not reverses a True/False result: not True is False, not False is True.
2not acts on one expression; and and or each combine two.
3Evaluate the inner comparison first, then apply not to its result.
4In a selection statement, True runs the if branch and False runs the else branch, so flipping the condition flips the route.

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?
and, or and not.
What does a logical expression evaluate to?
A single value: either True or False.
How do relational operators and logical operators differ?
Relational operators compare values. Logical operators combine or reverse the True/False results of those comparisons.
How many expressions does not act on? And what about and and or?
not acts on a single expression. and and or each combine two.
What does the not operator do to a result?
It reverses it: True becomes False and False becomes True.
Complete the truth table for not A.
A = True gives not A = False. A = False gives not A = True.
When is a not-expression True?
When the relational expression it acts on is False.
In not (value > 7), what do you work out first?
The comparison inside the brackets. Then you reverse its True or False result.
The ten of spades is drawn. What does suit != "hearts" return, and why?
True, because the suit is spades, not hearts.
Which part of age > 12 and age < 60 is the logical operator?
and. It combines the two comparisons; > and < are the relational operators.
In a selection statement, which branch runs for a True condition? For a False one?
True runs the if branch. False runs the else branch.
How can adding not change which branch a program takes?
It reverses the condition, so a condition that was False becomes True (and the other way round), which sends the program down the other branch.
A friend says "not makes an expression False". Are they right?
No. not reverses the result, so not False is True.

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.