what is a Boolean python
#In programming you often need to know if an expression is True or False.
#You can evaluate any expression in Python, and get one of two answers,
#True or False. When you compare two values, the expression is evaluated
#and Python returns the Boolean answer:
#Example:
print(10 > 9) #This returns true because this calculation is true
print(10 == 9) #This returns false because this calculation is false
print(10 < 9) #This returns false because this calculation is false
#Print a message based on whether the condition is True or False:
#Example:
a = 200
b = 33
if b > a:
print("b is greater than a")
else:
print("b is not greater than a")
>>> # The not operator is the opposite of it
>>> not True
False
>>> not False
True
>>> # The and operator is True only if both are are true
>>> True and True
True
>>> False and True
False
>>> False and False
False
>>> # The or operator is True if either of them are true
>>> True or True
True
>>> False or True
True
>>> False or False
False
# Booleans represent one of two values: True or False.
# When you compare two values, the expression is evaluated and Python returns the Boolean answer:
print(10 > 9)
> True
print(10 < 9)
> False
# All True Examples
bool("abc")
bool(123)
bool(["apple", "cherry", "banana"])
# All False Examples
bool(False)
bool(None)
bool(0)
bool("")
bool(())
bool([])
bool({})