Boolean
A value that is either True or False.
A boolean (bool) holds one of just two values: True or False. Comparisons such as 5 > 3 evaluate to a boolean, and booleans drive if statements and while loops. Combine them with and, or, and not.
Python also treats other values as "truthy" or "falsy": 0, 0.0, an empty string, an empty list [], and None all count as false inside a condition.
is_open = True
print(5 > 3) # a comparison produces a boolean
print(is_open and False)
print(not is_open)
print(bool("")) # an empty string counts as False
Output
True False False False
Where this shows up in real Python
Booleans drive every decision: the condition in an if or while, validating input, and toggling features on or off.
Commonly used Boolean tools
and / or / not— combine and invert conditions== != < > <= >=— comparisons that produce True/Falseany(items) / all(items)— is any/are all of them truthybool(x)— see how a value is judged truthy or falsy
Official documentation: Python Library Reference: Truth Value Testing