Booleans
A free lesson from Swipe Coding · Python, level 2 · updated October 2026
By the Swipe team, founded by Colin · how we make lessons
A boolean is a value that can only ever be one of two things: True or False. In Python, these keywords are always capitalized — unlike many other languages where they're written lowercase — and they represent the type bool.
is_raining = True is_sunny = False print(type(is_raining)) # <class 'bool'>
Booleans usually come from comparisons, like checking whether one number is greater than another. Python's comparison operators — ==, !=, <, >, <=, >= — always produce a bool result.
age = 20 print(age >= 18) # True print(age == 21) # False
Every value in Python has a kind of built-in truthiness, even values that aren't actually booleans. When a value is used somewhere a True/False answer is needed (like an if statement), Python converts it automatically. Values that count as False are called falsy: the number 0, an empty string "", the special value None, and empty collections like an empty list []. Essentially every other value — including any nonzero number and any non-empty string — is truthy.
if "":
print("this will not print")
if "hello":
print("this will print") # non-empty strings are truthyIn Python, the two boolean values are written ____, always with a capital letter, unlike lowercase true/false in some other languages.
Which of these values is considered falsy in Python?
An empty list, [], is considered falsy in Python.
Keep your streak going in Swipe Coding
Swipe through every level of Python on your iPhone — with XP, stars, streaks, a personal advisor and the full track beyond these free levels.
Get the Swipe apps →