Make Decisions
Learn to control flow using decision-making.
We'll cover the following...
We'll cover the following...
Now it’s time to teach Python how to make decisions like you do every day.
Press + to interact
In this lesson, we’ll learn how to write programs that react to different conditions using if
, else
, and elif
.
Try this:
Press + to interact
Python
age = 18if 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 ...