Back to Course

Introduction to Python

0% Complete
0/0 Steps
  1. Python: Basics
    14Topics
    |
    15 Quizzes
  2. Python: Control Flow
    12Topics
    |
    12 Quizzes
  3. Python: Errors
    5Topics
    |
    5 Quizzes
Lesson 2, Topic 8
In Progress

Python: Boolean Operator Not

Yasin Cakal 17 Oct 2021
Lesson Progress
0% Complete

The final boolean operator discussed in this section is not. This operator is self-explanatory: it reverses the value of any boolean expression. Thus, when we apply a not operator to a True statement, we obtain a False statement. Let’s take a look at some Python examples:

print(not True) # Prints False
print(not False) # Prints True

print(not 1 > 2)
print(not 5 < 4 and not 5==4)

Output:

False
True
True
True

Notice on the last print function where we combine boolean operators. Here is how you would evaluate it step by step:

  1. not 5 < 4 and not 5==4
  2. not False and not False
  3. True and True
  4. True

%d bloggers like this: