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, and elif statements
  • Lean how to use logical operators
  • Learn how to use comparison operators

Lesson Outline

  1. Append Recap
  2. If Statements
  3. Booleans
  4. If Statement Fundamentals
  5. The Average Ratings of Non-free Apps
  6. The Average Rating of Gaming Apps
  7. Multiple Conditions
  8. Review
  9. Takeaways

Get started for free

No credit card required.

Or With

By creating an account you agree to accept our terms of use and privacy policy.