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?

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"? Nope, it's spades, so A is False. Now not gets to work on that one result and reverses it: 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"? Nope, it's spades, so A is False. Now not gets to work on that one result and reverses it: not False is True..

Watch out: Don't stop at the A column. A is only the comparison. The answer to not A is the reverse of it.

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.

7 of 7 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, 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.

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

An if/else 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").

Be honest: 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

  • 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

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 comparison inside the brackets first, then apply not to its result.
4In an if/else 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") 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?
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.
Is != a relational operator or a logical operator?
Relational. It compares two values to see if they are different. not is the logical one: it reverses a result.
Which part of age > 12 and age < 60 is the logical operator?
and. It combines the two comparisons; > and < are the relational operators.
In an if/else 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 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.