Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Capstone Challenge | Conditional Statements
Introduction to Python Video Course
course content

Зміст курсу

Introduction to Python Video Course

Introduction to Python Video Course

1. Getting Started
2. Variables and Types
3. Conditional Statements
4. Other Data Types
5. Loops
6. Functions

Capstone Challenge

Congratulations on reaching this point in the course! In this capstone challenge, you will manage perishable products at a grocery store, determining discounts based on product expiration and stock levels. Your goal is to minimize waste while effectively maximizing sales through strategic discounting.

Let's see how well you can translate business rules into Python code!

Scenario

As a manager at a grocery store, you are responsible for implementing a discount strategy for perishable products based on their expiration date and stock levels.

The discount strategy is as follows:

  • Apply a 30% discount if the product expires in 3 days or less and the stock level is over 50 units;
  • Apply a 20% discount if the product expires in 4 to 6 days and the stock level is over 50 units;
  • Apply a 10% discount if the product expires in 7 days or more, or if the stock level is 50 units or less;
  • No discount if the product is not "Perishable".

Завдання

  1. Begin with an if statement to verify if the product_type is "Perishable". This initial check determines whether any discount logic should be applied at all.
  2. Nested inside the initial if statement, add another if condition to check for a 30% discount. This discount applies if the days_until_expiration is equal to or less than 3 days and the stock_level is greater than 50.
  3. Following the nested if statement, utilize an elif condition to check for a 20% discount. This elif will apply a discount if the days_until_expiration is greater than 3 days and equal to or less than 6 days, and the stock_level is greater than 50.
  4. Add a final elif statement for applying a 10% discount. This elif will apply a discount if the days_until_expiration is greater than 6 days and the stock_level is equal to or less than 50.

Note

You'll notice that we've placed an if statement inside another if statement. It's perfectly fine to nest multiple if statements, and you can even do this several levels deep.

Think of each block of code that starts after a colon (:) and is indented as a separate, independent piece of code. Just be sure to manage the indentation correctly for each nested block.

Завдання

  1. Begin with an if statement to verify if the product_type is "Perishable". This initial check determines whether any discount logic should be applied at all.
  2. Nested inside the initial if statement, add another if condition to check for a 30% discount. This discount applies if the days_until_expiration is equal to or less than 3 days and the stock_level is greater than 50.
  3. Following the nested if statement, utilize an elif condition to check for a 20% discount. This elif will apply a discount if the days_until_expiration is greater than 3 days and equal to or less than 6 days, and the stock_level is greater than 50.
  4. Add a final elif statement for applying a 10% discount. This elif will apply a discount if the days_until_expiration is greater than 6 days and the stock_level is equal to or less than 50.

Note

You'll notice that we've placed an if statement inside another if statement. It's perfectly fine to nest multiple if statements, and you can even do this several levels deep.

Think of each block of code that starts after a colon (:) and is indented as a separate, independent piece of code. Just be sure to manage the indentation correctly for each nested block.

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів

Все було зрозуміло?

Секція 3. Розділ 6
toggle bottom row

Capstone Challenge

Congratulations on reaching this point in the course! In this capstone challenge, you will manage perishable products at a grocery store, determining discounts based on product expiration and stock levels. Your goal is to minimize waste while effectively maximizing sales through strategic discounting.

Let's see how well you can translate business rules into Python code!

Scenario

As a manager at a grocery store, you are responsible for implementing a discount strategy for perishable products based on their expiration date and stock levels.

The discount strategy is as follows:

  • Apply a 30% discount if the product expires in 3 days or less and the stock level is over 50 units;
  • Apply a 20% discount if the product expires in 4 to 6 days and the stock level is over 50 units;
  • Apply a 10% discount if the product expires in 7 days or more, or if the stock level is 50 units or less;
  • No discount if the product is not "Perishable".

Завдання

  1. Begin with an if statement to verify if the product_type is "Perishable". This initial check determines whether any discount logic should be applied at all.
  2. Nested inside the initial if statement, add another if condition to check for a 30% discount. This discount applies if the days_until_expiration is equal to or less than 3 days and the stock_level is greater than 50.
  3. Following the nested if statement, utilize an elif condition to check for a 20% discount. This elif will apply a discount if the days_until_expiration is greater than 3 days and equal to or less than 6 days, and the stock_level is greater than 50.
  4. Add a final elif statement for applying a 10% discount. This elif will apply a discount if the days_until_expiration is greater than 6 days and the stock_level is equal to or less than 50.

Note

You'll notice that we've placed an if statement inside another if statement. It's perfectly fine to nest multiple if statements, and you can even do this several levels deep.

Think of each block of code that starts after a colon (:) and is indented as a separate, independent piece of code. Just be sure to manage the indentation correctly for each nested block.

Завдання

  1. Begin with an if statement to verify if the product_type is "Perishable". This initial check determines whether any discount logic should be applied at all.
  2. Nested inside the initial if statement, add another if condition to check for a 30% discount. This discount applies if the days_until_expiration is equal to or less than 3 days and the stock_level is greater than 50.
  3. Following the nested if statement, utilize an elif condition to check for a 20% discount. This elif will apply a discount if the days_until_expiration is greater than 3 days and equal to or less than 6 days, and the stock_level is greater than 50.
  4. Add a final elif statement for applying a 10% discount. This elif will apply a discount if the days_until_expiration is greater than 6 days and the stock_level is equal to or less than 50.

Note

You'll notice that we've placed an if statement inside another if statement. It's perfectly fine to nest multiple if statements, and you can even do this several levels deep.

Think of each block of code that starts after a colon (:) and is indented as a separate, independent piece of code. Just be sure to manage the indentation correctly for each nested block.

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів

Все було зрозуміло?

Секція 3. Розділ 6
toggle bottom row

Capstone Challenge

Congratulations on reaching this point in the course! In this capstone challenge, you will manage perishable products at a grocery store, determining discounts based on product expiration and stock levels. Your goal is to minimize waste while effectively maximizing sales through strategic discounting.

Let's see how well you can translate business rules into Python code!

Scenario

As a manager at a grocery store, you are responsible for implementing a discount strategy for perishable products based on their expiration date and stock levels.

The discount strategy is as follows:

  • Apply a 30% discount if the product expires in 3 days or less and the stock level is over 50 units;
  • Apply a 20% discount if the product expires in 4 to 6 days and the stock level is over 50 units;
  • Apply a 10% discount if the product expires in 7 days or more, or if the stock level is 50 units or less;
  • No discount if the product is not "Perishable".

Завдання

  1. Begin with an if statement to verify if the product_type is "Perishable". This initial check determines whether any discount logic should be applied at all.
  2. Nested inside the initial if statement, add another if condition to check for a 30% discount. This discount applies if the days_until_expiration is equal to or less than 3 days and the stock_level is greater than 50.
  3. Following the nested if statement, utilize an elif condition to check for a 20% discount. This elif will apply a discount if the days_until_expiration is greater than 3 days and equal to or less than 6 days, and the stock_level is greater than 50.
  4. Add a final elif statement for applying a 10% discount. This elif will apply a discount if the days_until_expiration is greater than 6 days and the stock_level is equal to or less than 50.

Note

You'll notice that we've placed an if statement inside another if statement. It's perfectly fine to nest multiple if statements, and you can even do this several levels deep.

Think of each block of code that starts after a colon (:) and is indented as a separate, independent piece of code. Just be sure to manage the indentation correctly for each nested block.

Завдання

  1. Begin with an if statement to verify if the product_type is "Perishable". This initial check determines whether any discount logic should be applied at all.
  2. Nested inside the initial if statement, add another if condition to check for a 30% discount. This discount applies if the days_until_expiration is equal to or less than 3 days and the stock_level is greater than 50.
  3. Following the nested if statement, utilize an elif condition to check for a 20% discount. This elif will apply a discount if the days_until_expiration is greater than 3 days and equal to or less than 6 days, and the stock_level is greater than 50.
  4. Add a final elif statement for applying a 10% discount. This elif will apply a discount if the days_until_expiration is greater than 6 days and the stock_level is equal to or less than 50.

Note

You'll notice that we've placed an if statement inside another if statement. It's perfectly fine to nest multiple if statements, and you can even do this several levels deep.

Think of each block of code that starts after a colon (:) and is indented as a separate, independent piece of code. Just be sure to manage the indentation correctly for each nested block.

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів

Все було зрозуміло?

Congratulations on reaching this point in the course! In this capstone challenge, you will manage perishable products at a grocery store, determining discounts based on product expiration and stock levels. Your goal is to minimize waste while effectively maximizing sales through strategic discounting.

Let's see how well you can translate business rules into Python code!

Scenario

As a manager at a grocery store, you are responsible for implementing a discount strategy for perishable products based on their expiration date and stock levels.

The discount strategy is as follows:

  • Apply a 30% discount if the product expires in 3 days or less and the stock level is over 50 units;
  • Apply a 20% discount if the product expires in 4 to 6 days and the stock level is over 50 units;
  • Apply a 10% discount if the product expires in 7 days or more, or if the stock level is 50 units or less;
  • No discount if the product is not "Perishable".

Завдання

  1. Begin with an if statement to verify if the product_type is "Perishable". This initial check determines whether any discount logic should be applied at all.
  2. Nested inside the initial if statement, add another if condition to check for a 30% discount. This discount applies if the days_until_expiration is equal to or less than 3 days and the stock_level is greater than 50.
  3. Following the nested if statement, utilize an elif condition to check for a 20% discount. This elif will apply a discount if the days_until_expiration is greater than 3 days and equal to or less than 6 days, and the stock_level is greater than 50.
  4. Add a final elif statement for applying a 10% discount. This elif will apply a discount if the days_until_expiration is greater than 6 days and the stock_level is equal to or less than 50.

Note

You'll notice that we've placed an if statement inside another if statement. It's perfectly fine to nest multiple if statements, and you can even do this several levels deep.

Think of each block of code that starts after a colon (:) and is indented as a separate, independent piece of code. Just be sure to manage the indentation correctly for each nested block.

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Секція 3. Розділ 6
Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
We're sorry to hear that something went wrong. What happened?
some-alt