Booleans represent one of two values: True or False.
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.
print(10 > 9) // True print(10 == 9) // False print(10 < 9) // False
The bool() function allows you to evaluate any value, and give you True or False in return.
print(bool("Hello")) // True
print(bool(15)) // True
Almost any value is evaluated to True if it has some sort of content.
True, except empty strings.True, except 0.True, except empty ones.In fact, there are not many values that evaluate to False, except empty values, such as (), [], {}, "", the number 0, and the value None. And of course the value False evaluates to False.
print(bool(False))
print(bool(None))
print(bool(0))
print(bool(""))
print(bool(()))
print(bool([]))
print(bool({}))
Which of the following evaluates to `False` in Python?