Swipe
SwipeSwipe
Swipe Apps

Paths

Motivation

Information

Booleans & Type Conversion · Lesson 10 of 11

Booleans

A free lesson from Swipe Coding · Python, level 2 · updated October 2026

By the Swipe team, founded by Colin · how we make lessons

🤖
Only two possible values here, but they secretly power every if statement you'll ever write. 🐍

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'>
True and False are capitalized keywords in Python, and both are values of type 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
Comparison operators evaluate to True or False, which you can store in a variable or use directly.
🤖
Even non-boolean values secretly have an opinion about True or False here. 🔍

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 truthy
An empty string is falsy, so its if block is skipped; a non-empty string is truthy, so its block runs.
Fill in the blank

In Python, the two boolean values are written ____, always with a capital letter, unlike lowercase true/false in some other languages.

Quick check

Which of these values is considered falsy in Python?

True or false

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 →