Python Boolean: Difference between revisions
Jump to navigation
Jump to search
Line 8: | Line 8: | ||
<class 'bool'> | <class 'bool'> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=What is True?= | |||
=Operators= | =Operators= |
Revision as of 05:01, 19 June 2022
Internal
Overview
A boolean can be True
or False
.
x = True
type(x)
<class 'bool'>
What is True?
Operators
OR: | and |=
assert (True | True)
assert (True | False)
assert (False | True)
assert not (False | False)
l = [True, False]
b = False
for e in l:
b |= e
assert b
l = [False, False]
b = False
for e in l:
b |= e
assert not b
Note that +
applied to booleans contest to integers.