Python Not Boolean Operator Tutorial

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/python-not-boolean-operator-tutorial/
PINTEREST
PINTEREST
INSTAGRAM

Python provides wide range of the logical operators. One type of logical operator is boolean operators where we can check the similarity or equality of the given data or variables. In this tutorial we will examine the not Boolean operator which can be used inequality of the provided values or data.

Check If Not Equal

We will start with a simple example where we will check whether given variable age is 10 . We will use not operator. We should use not operator with is operator like below.

Check If Not Equal
Check If Not Equal

Not Operator Sign !=

We have alternative way to express not logic. We can use != operator sign the same fashion as not . We will use previous example again with != which check if the age variable is not 10.

Not Operator Sign !=
Not Operator Sign !=

Check If Not Exist In Given List or Array

Another useful usage case for not operator is checking given value or variable against a list or set. In this example we will check whether variable a value exist in the given list.

Check If Not Exist In Given List or Array
Check If Not Exist In Given List or Array

Not Not

As not is logical operation we can use it multiple times in a single expression. In this example we will not two times for single value. In this case we will not True value two times. At first it will be false but with the second not it will be True again.

LEARN MORE  Python Boolean Variable Types

Not Not
Not Not

Noting Variable

We can also not given data or variable. In this case we will not number 10 and check if equal with 10 .

Noting Variable
Noting Variable

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/python-not-boolean-operator-tutorial/
PINTEREST
PINTEREST
INSTAGRAM