This Python program demonstrates how logical operations AND, OR, and NOT behave when applied to boolean values.
It converts the result of each operation into a numeric value: True → 1, False → 0.
# Define sample boolean values
a = True
b = False
# Logical operations and numeric conversion
and_result = int(a and b)
or_result = int(a or b)
not_result = int(not a)
# Display results
print("AND (True && False):", and_result)
print("OR (True || False):", or_result)
print("NOT (!True):", not_result)
AND (True && False): 0
OR (True || False): 1
NOT (!True): 0
- a and b returns Falseint(False) = 0
- a or b returns Trueint(True) = 1
- not a returns Falseint(False) = 0
- The int() function converts boolean results to numeric form