Boolean
In one line
A boolean (bool) is a type with two values: True or False, used for logic and conditions.
In simple words
A boolean represents truth — it has exactly two values: True and False (capitalized in Python). Booleans are used in if conditions, while loops, and logical operations.
Booleans result from comparisons (>, <, ==, !=, in, is) and logical operators (and, or, not). In Python, bool is a subclass of int — True is 1 and False is 0, so you can use them in arithmetic.
Python has the concept of truthy and falsy values. Falsy values are: False, 0, 0.0, '', [], {}, None. Everything else is truthy. This lets you write concise conditions like if my_list: instead of if len(my_list) > 0:.
Example
is_active = True
is_admin = False
print(is_active and is_admin) # False
print(is_active or is_admin) # True
print(not is_admin) # True
print(True + True) # 2 (bool is subclass of int)
# Truthy/falsy
if []:
print("empty list is truthy")
else:
print("empty list is falsy") # This printsBooleans are True/False, support logical operators, and have truthy/falsy semantics.
Common confusions
Confused with: integer
The difference: bool is a subclass of int in Python. True == 1 and False == 0. But booleans represent logical truth, while integers represent quantities. Use bool() to convert any value to its truthy/falsy boolean.
Related terms
Related Resources
Related Lessons
- Data Types
Boolean type.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.