Booleans and None
True, False, truthiness, and the value that means "nothing".
3 minute read
Big idea
A boolean (bool) is either True or False — the answer to a yes/no question. None means "no value at all".
Booleans
is_raining = True
has_umbrella = False
Capital T, capital F, no quotes. You'll rarely type them directly, though — they usually come from a comparison:
age = 15
print(age >= 13)
print(age >= 18)
print(type(age >= 18))output
True
False
<class 'bool'>Run and edit it in the app.
Every if and every loop you'll write in this course runs on booleans.
Truthy and falsy
Python can treat any value as true or false. bool(...) shows you which. The rule: empty or zero is False; everything else is True.
print(bool(0))
print(bool(42))
print(bool(""))
print(bool("no"))
print(bool(None))What does it print? Show the answer
False
True
False
True
FalseRun and edit it in the app.
"no" is True — it's a non-empty string. Python doesn't read the word.
Watch it
None
None is Python's "nothing here". It's used for "not set yet" or "no answer":
winner = None # no winner yet
To check for it, use is:
winner = None
print(winner is None)
winner = "Grace"
print(winner is None)output
True
FalseRun and edit it in the app.
It's its own type — type(None) is NoneType — and it isn't the same as 0, "", or False, even though all of them are falsy.
ready = true
print(ready)output
TrueRun and edit it in the app.
Which of these is truthy?
Think of it like
A light switch: True is on, False is off. None is a switch that hasn't been installed yet.
Key terms
- Boolean (bool) —
TrueorFalse. - Truthy / falsy — Whether a value counts as true or false; empty and zero are falsy.
- None — The value meaning "nothing".
Check yourself
What does 10 > 3 give?
Which value is falsy?
How should you check whether x is None?