Python Booleans

True, False and truth values.

✍️ 3 exercises + code challenge in this lesson

Booleans represent one of two values: True or False. Comparisons return booleans.

Almost any value can be evaluated with bool(). These are False:

False, None, 0, 0.0, "", [], (), {}, set()

Everything else is True.

Key Takeaways: Python Booleans

Mastering Python Booleans helps you write clean and reliable Python code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.

Python Booleans Code Example

Python
print(10 > 9)
print(10 == 9)
print(bool("Hello"), bool(15))
print(bool(""), bool(0), bool([]), bool(None))

cart = []
if not cart:
    print("Your cart is empty")
Free sign-in required · Google login available

Python Booleans Practice Exercises

Check what you learned in “Python Booleans”.

/ 3 solved
Fill in the blank

Write the boolean value for "yes".

is_open = 
✓ Correct! Not quite. Try again.
Multiple choice

Which of these is False when converted with bool()?

✓ Correct! Not quite. Try again.
Code challenge

Print the result of bool([]).

Write the code in the live editor. Your answer is checked automatically.

Free sign-in required · Google login available

to save your exercise progress.
Finished this lesson?
Mark it complete to track your progress.

Stuck on something?

Ask the community in the CodesInTech forum.

Need a developer?

Learning on your own is great — and when you need professional help, our team builds custom software, websites and mobile apps for clients worldwide.

Explore Our Services