*Memo:
-
My post explains how to create
False.
<bool()>:
print(bool(True)) # bool
print(bool(1)) # int
print(bool(-1)) # int
print(bool(1.0)) # float
print(bool(-1.0)) # float
print(bool(float('nan'))) # float('nan')
print(bool(float('-nan'))) # float('-nan')
print(bool(float('inf'))) # float('inf')
print(bool(float('-inf'))) # float('-inf')
print(bool(1.0+1.0j)) # complex
print(bool(-1.0-1.0j)) # complex
print(bool(complex('nan+nanj'))) # complex('nan+nanj')
print(bool(complex('-nan-nanj'))) # complex('-nan-nanj')
print(bool(complex('inf+infj'))) # complex('inf+infj')
print(bool(complex('-inf-infj'))) # complex('-inf-infj')
print(bool([0])) # list
print(bool([[]])) # list(Empty list)
print(bool((0,))) # tuple
print(bool(((),))) # tuple(Empty tuple)
print(bool({0})) # set
print(bool({frozenset()})) # set(Empty frozenset)
print(bool(frozenset({0}))) # frozenset
print(bool(frozenset([frozenset([])]))) # frozenset(Empty frozenset)
print(bool({0:0})) # dict
print(bool({():()})) # dict(Empty tuple:Empty tuple)
print(bool(iter([]))) # Empty iterator
print(bool(iter([0]))) # iterator
print(bool(iter([iter([])]))) # iterator(Empty iterator)
print(bool(' ')) # str
print(bool(b' ')) # bytes
print(bool(bytearray(b' '))) # bytearray
print(bool(range(1))) # range
# True
<not>:
print(not False) # bool
print(not None) # None
print(not 0) # int
print(not 0.0) # float
print(not 0.0+0.0j) # complex
print(not []) # Empty list
print(not ()) # Empty tuple
print(not set()) # Empty set
print(not frozenset([])) # Empty frozenset
print(not {}) # Empty dict
print(not '') # Empty str
print(not b'') # Empty bytes
print(not bytearray(b'')) # Empty bytearray
print(not range(0)) # Empty range
# True
<Others>:
print(5 < 10) # <
print(10 > 5) # >
print(5 <= 10) # <=
print(10 >= 5) # >=
print(10 == 10) # ==
print(10 != 5) # !=
print(10 in [10]) # in
print(not False) # not
print(True & True) # &
print(True and True) # and
print(True or False) # or
print(False or True) # or
print(True | False) # |
print(False | True) # |
print(True ^ False) # ^
print(False ^ True) # ^
v1, v2 = [10, 10]
print(v1 is v2) # is
v1, v2 = [10, 5]
print(v1 is not v2) # is not
# True
Top comments (0)