Logical operations

Basic types / Boolean

value1 = True
value2 = False

value_not1 = not value1
# value_not1 is False

value_not2 = not value2
# value_not2 is True

value_and = value1 and value2
# value_and is False

value_or = value1 or value2
# value_or is True

value_xor = value1 ^ value2
# value_xor is True

# and, or return one of the operands, not True or False
last_operand = 1 and 2
# last_operand is 2

with_default = None or "found"
# with_default is 'found'

print(f"{value_not1 = }")
print(f"{value_not2 = }")
print(f"{value_and = }")
print(f"{value_or = }")
print(f"{value_xor = }")
print(f"{last_operand = }")
print(f"{with_default = }")