single
Challenge: Pricing Adjustment Capstone
Swipe to show menu
You are managing a grocery store's system, and you need to maintain decision-making for the inventory, track prices, and perform checks to determine if actions like restocking or removing items from the inventory are needed based on their price or stock.
Swipe to start coding
You're managing a grocery store inventory stored as a Python dictionary. Each item has a category, price, and stock quantity.
Complete the following steps in order:
-
Create the
grocery_inventorydictionary using the data from the table above. Each value is a tuple of(category, price, stock). -
Update Eggs price — if it exceeds $5, print
"Eggs are too expensive, reducing the price by $1."and reduce the price by $1. Otherwise print"The price of Eggs is reasonable." -
Add Tomatoes — category
"Produce", price$1.20, stock30. Then print the full inventory with the message"Inventory after adding Tomatoes:". -
Restock Milk — if stock is below 10, add 20 units and print
"Milk needs to be restocked. Increasing stock by 20 units."Otherwise print"Milk has sufficient stock." -
Remove Apples — if the price exceeds $2, remove the item and print
"Apples removed from inventory due to high price." -
Print the final inventory with the message
"Updated inventory:".
Solution
Thanks for your feedback!
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat