Boolean Data Object
Boolean is named after Mathematician George Boole.
The Boolean data type allow us to implement logic in our code by simplifying statements to be either True or False.
There are two Boolean data-typed possible values in Python.
True
False
Usage:
We can set variables with Boolean values
We can get them as a result from Comparison, Logical, and Membership operations
Certain functions and methods will result in a Boolean value as well
Truthy and Falsy Values in Python 3
In programming (Python), certain values can be also True or False in Conditional Situations. We call these Truthy or Falsy values.
The rules are as follows:
Idea of Emptiness is
False
→ Keyword:None
isFalse
Therefore,
0, '', "" , []
are all empty → False1 represents “ON” in binary →
True
; 0 →False
Lastly, ANY NON-FALSY values are True
Type Conversion Function: bool()
bool()
The built-in function to convert one data value to Boolean is: bool()
Last updated