
Python Data Structures and Algorithms
By :

There are a number of operations that are common to all data types. For example, all data types, and generally all objects, can be tested for a truth value in some way. The following are values that Python considers False
:
None
typeFalse
__len__()
or __bool__()
method that returns zero or False
All other values are consideredTrue
.
A Boolean operation returns a value of either True
or False
. Boolean operations are ordered in priority, so if more than one Boolean operation occurs in an expression, the operation with the highest priority will occur first. The following table outlines the three Boolean operators in descending order of priority:
Operator | Example |
not | Returns |
| Returns |
| Returns |