python boolean function code example
Example 1: Which of the following is a Boolean in Python?
>>> type(True)
<class 'bool'>
>>> type(true)
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
NameError: name 'true' is not defined
Example 2: python boolean operators
>>>
>>> not True
False
>>> not False
True
>>>
>>> True and True
True
>>> False and True
False
>>> False and False
False
>>>
>>> True or True
True
>>> False or True
True
>>> False or False
False
Example 3: python bool()
x = bool(1)