Course Content
Introduction to Python Video Course
Introduction to Python Video Course
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".
Task
- Begin with an
if
statement to verify if theproduct_type
is"Perishable"
. This initial check determines whether any discount logic should be applied at all. - Nested inside the initial
if
statement, add anotherif
condition to check for a 30% discount. This discount appliesif
thedays_until_expiration
is equal to or less than3
daysand
thestock_level
is greater than50
. - Following the nested
if
statement, utilize anelif
condition to check for a 20% discount. Thiselif
will apply a discount if thedays_until_expiration
is greater than3
daysand
equal to or less than6
days,and
thestock_level
is greater than50
. - Add a final
elif
statement for applying a 10% discount. Thiselif
will apply a discount if thedays_until_expiration
is greater than6
daysand
thestock_level
is equal to or less than50
.
Note
You'll notice that we've placed an
if
statement inside anotherif
statement. It's perfectly fine to nest multipleif
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.
Task
- Begin with an
if
statement to verify if theproduct_type
is"Perishable"
. This initial check determines whether any discount logic should be applied at all. - Nested inside the initial
if
statement, add anotherif
condition to check for a 30% discount. This discount appliesif
thedays_until_expiration
is equal to or less than3
daysand
thestock_level
is greater than50
. - Following the nested
if
statement, utilize anelif
condition to check for a 20% discount. Thiselif
will apply a discount if thedays_until_expiration
is greater than3
daysand
equal to or less than6
days,and
thestock_level
is greater than50
. - Add a final
elif
statement for applying a 10% discount. Thiselif
will apply a discount if thedays_until_expiration
is greater than6
daysand
thestock_level
is equal to or less than50
.
Note
You'll notice that we've placed an
if
statement inside anotherif
statement. It's perfectly fine to nest multipleif
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.
Everything was clear?
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".
Task
- Begin with an
if
statement to verify if theproduct_type
is"Perishable"
. This initial check determines whether any discount logic should be applied at all. - Nested inside the initial
if
statement, add anotherif
condition to check for a 30% discount. This discount appliesif
thedays_until_expiration
is equal to or less than3
daysand
thestock_level
is greater than50
. - Following the nested
if
statement, utilize anelif
condition to check for a 20% discount. Thiselif
will apply a discount if thedays_until_expiration
is greater than3
daysand
equal to or less than6
days,and
thestock_level
is greater than50
. - Add a final
elif
statement for applying a 10% discount. Thiselif
will apply a discount if thedays_until_expiration
is greater than6
daysand
thestock_level
is equal to or less than50
.
Note
You'll notice that we've placed an
if
statement inside anotherif
statement. It's perfectly fine to nest multipleif
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.
Task
- Begin with an
if
statement to verify if theproduct_type
is"Perishable"
. This initial check determines whether any discount logic should be applied at all. - Nested inside the initial
if
statement, add anotherif
condition to check for a 30% discount. This discount appliesif
thedays_until_expiration
is equal to or less than3
daysand
thestock_level
is greater than50
. - Following the nested
if
statement, utilize anelif
condition to check for a 20% discount. Thiselif
will apply a discount if thedays_until_expiration
is greater than3
daysand
equal to or less than6
days,and
thestock_level
is greater than50
. - Add a final
elif
statement for applying a 10% discount. Thiselif
will apply a discount if thedays_until_expiration
is greater than6
daysand
thestock_level
is equal to or less than50
.
Note
You'll notice that we've placed an
if
statement inside anotherif
statement. It's perfectly fine to nest multipleif
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.
Everything was clear?
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".
Task
- Begin with an
if
statement to verify if theproduct_type
is"Perishable"
. This initial check determines whether any discount logic should be applied at all. - Nested inside the initial
if
statement, add anotherif
condition to check for a 30% discount. This discount appliesif
thedays_until_expiration
is equal to or less than3
daysand
thestock_level
is greater than50
. - Following the nested
if
statement, utilize anelif
condition to check for a 20% discount. Thiselif
will apply a discount if thedays_until_expiration
is greater than3
daysand
equal to or less than6
days,and
thestock_level
is greater than50
. - Add a final
elif
statement for applying a 10% discount. Thiselif
will apply a discount if thedays_until_expiration
is greater than6
daysand
thestock_level
is equal to or less than50
.
Note
You'll notice that we've placed an
if
statement inside anotherif
statement. It's perfectly fine to nest multipleif
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.
Task
- Begin with an
if
statement to verify if theproduct_type
is"Perishable"
. This initial check determines whether any discount logic should be applied at all. - Nested inside the initial
if
statement, add anotherif
condition to check for a 30% discount. This discount appliesif
thedays_until_expiration
is equal to or less than3
daysand
thestock_level
is greater than50
. - Following the nested
if
statement, utilize anelif
condition to check for a 20% discount. Thiselif
will apply a discount if thedays_until_expiration
is greater than3
daysand
equal to or less than6
days,and
thestock_level
is greater than50
. - Add a final
elif
statement for applying a 10% discount. Thiselif
will apply a discount if thedays_until_expiration
is greater than6
daysand
thestock_level
is equal to or less than50
.
Note
You'll notice that we've placed an
if
statement inside anotherif
statement. It's perfectly fine to nest multipleif
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.
Everything was clear?
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".
Task
- Begin with an
if
statement to verify if theproduct_type
is"Perishable"
. This initial check determines whether any discount logic should be applied at all. - Nested inside the initial
if
statement, add anotherif
condition to check for a 30% discount. This discount appliesif
thedays_until_expiration
is equal to or less than3
daysand
thestock_level
is greater than50
. - Following the nested
if
statement, utilize anelif
condition to check for a 20% discount. Thiselif
will apply a discount if thedays_until_expiration
is greater than3
daysand
equal to or less than6
days,and
thestock_level
is greater than50
. - Add a final
elif
statement for applying a 10% discount. Thiselif
will apply a discount if thedays_until_expiration
is greater than6
daysand
thestock_level
is equal to or less than50
.
Note
You'll notice that we've placed an
if
statement inside anotherif
statement. It's perfectly fine to nest multipleif
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.