L1·Foundations
✅Booleans & Truthiness
True, False, and what counts as 'truthy'.
booltruthyandornot
§ 1Falsy values
False, None, 0, 0.0, "", [], {}, (), set() — everything else is truthy.
§ 2Short-circuit
and returns the first falsy operand (or last). or returns the first truthy operand (or last). Not always a bool!
§ 3Chained comparisons
a < b < c is (a < b) and (b < c), evaluating b once.
Example
1print(bool([])) # False2print(bool("0")) # True (non-empty!)3print(0 or "default") # 'default'4print(1 < 2 < 3) # TrueTry it live · Python runs in your browser
Loading playground…
Checkpoint quiz
Question 1 / 3
bool('False') is: