The Python Boolean type is one of Python’s built-in data types. It’s used to represent the truth value of an expression. For example, the expression 1 <= 2 is True, while the expression 0 == 1 is False. Understanding how Python Boolean values behave is important to programming well in Python.
In this tutorial, you’ll learn how to:
- Manipulate Boolean values with Boolean operators
- Convert Booleans to other types
- Convert other types to Python Booleans
- Use Python Booleans to write efficient and readable Python code
Free Bonus: 5 Thoughts On Python Mastery, a free course for Python developers that shows you the roadmap and the mindset you’ll need to take your Python skills to the next level.
The Python Boolean Type
The Python Boolean type has only two possible values:
TrueFalse
No other value will have bool as its type. You can check the type of True and False with the built-in type():