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.
In this lesson, we’ll learn how to write programs that react to different conditions using if
, else
, and elif
.
Try this:
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 ...