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

Conteúdo do Curso

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".

Tarefa

  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.

Tarefa

  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.

Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo

Tudo estava claro?

Seção 3. Capítulo 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".

Tarefa

  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.

Tarefa

  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.

Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo

Tudo estava claro?

Seção 3. Capítulo 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".

Tarefa

  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.

Tarefa

  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.

Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo

Tudo estava claro?

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".

Tarefa

  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.

Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Seção 3. Capítulo 6
Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
We're sorry to hear that something went wrong. What happened?
some-alt