Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
If/Elif/Else | Introduction to Python 2/2
Introduction to Python for Data Analysis
course content

Course Content

Introduction to Python for Data Analysis

Introduction to Python for Data Analysis

1. Introduction to Python 1/2
2. Introduction to Python 2/2
3. Explore Dataset
4. Becoming an Analyst

If/Elif/Else

If we want to add one additional cases in the problem we need to use elif statement.

carousel-imgcarousel-imgcarousel-img

If you want to go deeper into if/elif/else statements, we have a course with more tasks to learn more about if/else blocks.

Let's add an additional case to the problem from the previous task.

Task

Do you recall analysts from the if-else chapter? They decided to set new discounts. If the price is bigger than 25, the discount will be 25%; if the price is lower than or equals 25, the discount will be 15%. Otherwise, 5%.

  1. Set the condition if the price is bigger than 25.
  2. Set the 25% discount if the price is greater than 25.
  3. Set the condition if the price is lower than or equals 25 or greater the 10.
  4. Set the 15% discount in case of the 3. item. !
  5. Otherwise, set the 5% discount.
  6. Print the price_upd.

! To set the 15% discount use value * 0.85

Task

Do you recall analysts from the if-else chapter? They decided to set new discounts. If the price is bigger than 25, the discount will be 25%; if the price is lower than or equals 25, the discount will be 15%. Otherwise, 5%.

  1. Set the condition if the price is bigger than 25.
  2. Set the 25% discount if the price is greater than 25.
  3. Set the condition if the price is lower than or equals 25 or greater the 10.
  4. Set the 15% discount in case of the 3. item. !
  5. Otherwise, set the 5% discount.
  6. Print the price_upd.

! To set the 15% discount use value * 0.85

Everything was clear?

Section 2. Chapter 3
toggle bottom row

If/Elif/Else

If we want to add one additional cases in the problem we need to use elif statement.

carousel-imgcarousel-imgcarousel-img

If you want to go deeper into if/elif/else statements, we have a course with more tasks to learn more about if/else blocks.

Let's add an additional case to the problem from the previous task.

Task

Do you recall analysts from the if-else chapter? They decided to set new discounts. If the price is bigger than 25, the discount will be 25%; if the price is lower than or equals 25, the discount will be 15%. Otherwise, 5%.

  1. Set the condition if the price is bigger than 25.
  2. Set the 25% discount if the price is greater than 25.
  3. Set the condition if the price is lower than or equals 25 or greater the 10.
  4. Set the 15% discount in case of the 3. item. !
  5. Otherwise, set the 5% discount.
  6. Print the price_upd.

! To set the 15% discount use value * 0.85

Task

Do you recall analysts from the if-else chapter? They decided to set new discounts. If the price is bigger than 25, the discount will be 25%; if the price is lower than or equals 25, the discount will be 15%. Otherwise, 5%.

  1. Set the condition if the price is bigger than 25.
  2. Set the 25% discount if the price is greater than 25.
  3. Set the condition if the price is lower than or equals 25 or greater the 10.
  4. Set the 15% discount in case of the 3. item. !
  5. Otherwise, set the 5% discount.
  6. Print the price_upd.

! To set the 15% discount use value * 0.85

Everything was clear?

Section 2. Chapter 3
toggle bottom row

If/Elif/Else

If we want to add one additional cases in the problem we need to use elif statement.

carousel-imgcarousel-imgcarousel-img

If you want to go deeper into if/elif/else statements, we have a course with more tasks to learn more about if/else blocks.

Let's add an additional case to the problem from the previous task.

Task

Do you recall analysts from the if-else chapter? They decided to set new discounts. If the price is bigger than 25, the discount will be 25%; if the price is lower than or equals 25, the discount will be 15%. Otherwise, 5%.

  1. Set the condition if the price is bigger than 25.
  2. Set the 25% discount if the price is greater than 25.
  3. Set the condition if the price is lower than or equals 25 or greater the 10.
  4. Set the 15% discount in case of the 3. item. !
  5. Otherwise, set the 5% discount.
  6. Print the price_upd.

! To set the 15% discount use value * 0.85

Task

Do you recall analysts from the if-else chapter? They decided to set new discounts. If the price is bigger than 25, the discount will be 25%; if the price is lower than or equals 25, the discount will be 15%. Otherwise, 5%.

  1. Set the condition if the price is bigger than 25.
  2. Set the 25% discount if the price is greater than 25.
  3. Set the condition if the price is lower than or equals 25 or greater the 10.
  4. Set the 15% discount in case of the 3. item. !
  5. Otherwise, set the 5% discount.
  6. Print the price_upd.

! To set the 15% discount use value * 0.85

Everything was clear?

If we want to add one additional cases in the problem we need to use elif statement.

carousel-imgcarousel-imgcarousel-img

If you want to go deeper into if/elif/else statements, we have a course with more tasks to learn more about if/else blocks.

Let's add an additional case to the problem from the previous task.

Task

Do you recall analysts from the if-else chapter? They decided to set new discounts. If the price is bigger than 25, the discount will be 25%; if the price is lower than or equals 25, the discount will be 15%. Otherwise, 5%.

  1. Set the condition if the price is bigger than 25.
  2. Set the 25% discount if the price is greater than 25.
  3. Set the condition if the price is lower than or equals 25 or greater the 10.
  4. Set the 15% discount in case of the 3. item. !
  5. Otherwise, set the 5% discount.
  6. Print the price_upd.

! To set the 15% discount use value * 0.85

Section 2. Chapter 3
Switch to desktop for real-world practiceContinue from where you are using one of the options below
We're sorry to hear that something went wrong. What happened?
some-alt