Getting Started With Python's not Operator
00:00
Let’s take a look at how the not operator works in Python. Python uses not to implement the negation operation. Negation is a unary operation, meaning it takes just one expression as an operant.
00:16
In Python, that operand could be a Boolean expression or another type of Python object. If the operand it’s applied to evaluates to True, then the result of the not operation is False.
00:30
Similarly, if the operand evaluates to False, then the result of the not operation applied to it is True.
00:39
Many times, the function of Boolean operators is described in a truth table. Here is the one for not. It basically says that if the operand is True, then not operand is False.
00:52
And if the operand is False, then the not of it is True. Where might you use the not operator? One case is when you’re looking for a condition that isn’t met during some if or while statement, negating or inverting the value of a Boolean expression, checking to see if an item is not in a given collection of things, and in sometimes checking for object identity.
01:22 And this course will show you examples of all of these.
Become a Member to join the conversation.