Python If, Else, Elif Statements
Building upon the Python Lists lesson and the Python For Loops lesson, you’ll continue to develop your Python programming skills by learning to answer questions using conditional statements, such as if
, else
, and elif
statements.
In this lesson, you’ll learn concepts such as conditional statements to control the flow of your code, the Boolean values True
and False
, and how to use comparison operators such as ==
, and !=
. Combining all of these concepts is crucial for both a Python developer and a data scientist—the combination of Python conditionals gives you more control over your code. For example, if you have a list of mobile applications, and you want to compute the average, you could use conditional statements and comparison operators to see the average rating of apps that aren’t free vs. those that are free.
When you finish this lesson, you’ll feel more confident using For Loops and Conditional Statements in Python. If you feel like you need practice, feel free to think of something you can create using what you’ve learned so far; it doesn’t have to be big, it can be something practical, like using for loops and if
, else
, and elif
statements to perform calculations on a dataset.
Objectives
- Learn how to use Python conditionals such as
if
,else
, andelif
statements - Lean how to use logical operators
- Learn how to use comparison operators
Lesson Outline
- Append Recap
- If Statements
- Booleans
- If Statement Fundamentals
- The Average Ratings of Non-free Apps
- The Average Rating of Gaming Apps
- Multiple Conditions
- Review
- Takeaways
Get started for free
No credit card required.
By creating an account you agree to accept our terms of use and privacy policy.