Search⌘ K

Make Decisions

Explore how to make Python programs respond to different conditions by using if, else, and elif statements. Learn about code blocks, indentation, and comparison operators to control your program's flow effectively.

Now it’s time to teach Python how to make decisions like you do every day.


In this lesson, we’ll learn how to write programs that react to different conditions using if, else, and elif.


Try this:

Python
age = 18
if age >= 18:
print("You're an adult!")

Python checked the condition and ran the code only if it was true.

Note: In Python, a colon (:) starts a block of code—like after an if statement. The ...