Python Boolean Logic
In life, things can be nuanced. In programming, questions always boil down to two simple states: True or False. Is the password correct? True. Is the battery dead? False. Booleans are the master switches of all computing logic.
"Think of a light switch on the wall. It has only two possible positions: ON (True) or OFF (False). There is no "kinda ON" in computer hardware."
Deep Dive: How It Works
The boolean type (bool) in Python has exactly two literal values: True and False. Notice that in Python, both must start with a capital letter. Writing true or false in lowercase will cause a NameError.
Comparison expressions automatically evaluate to a boolean. For example, 10 > 5 evaluates to True, while 3 == 7 evaluates to False.
Truthy and Falsy values: In Python, every object has an inherent truth value. Empty containers (empty strings "", empty lists [], 0, and None) are considered Falsy (evaluating to False in conditions). Anything containing content or non-zero numbers is considered Truthy (evaluating to True).
Syntax Blueprint
is_active = True is_admin = False is_greater = 10 > 5 # Evaluates to True
Use capitalized True and False, or comparison operations that produce boolean results.
Core Rules to Remember



Common Beginner Traps & How to Fix Them
Writing lowercase true or falseWhy it happens: JavaScript, C++, and Java use lowercase true/false, so muscle memory kicks in.
How to fix: Always capitalize True and False in Python.
Live Interactive Example
Hit Run Code to see it liveYour Turn: Micro Challenge
No pressure! Edit the starter code below and test your solution with instant feedback.
Evaluate comparison boolean
Print the boolean result of checking if 100 is greater than 50 using print(100 > 50).
Finished reading and practicing?
Mark this lesson as completed to update your course progress.