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 steps in order:
-
Create the
grocery_inventorydictionary using the table above. Each value should be a tuple:(category, price, stock). -
Check
"Eggs"price. If it exceeds$5, reduce it by$1and print"Eggs are too expensive, reducing the price by $1."Otherwise, print"The price of Eggs is reasonable." -
Add
"Tomatoes"with category"Produce", price$1.20, and stock30. Then print"Inventory after adding Tomatoes:"and the full inventory. -
Store the current
"Milk"stock in a variable namedmilk_stock. If it is below10, add20units and print"Milk needs to be restocked. Increasing stock by 20 units."Otherwise, print"Milk has sufficient stock." -
If
"Apples"price exceeds$2, remove it and print"Apples removed from inventory due to high price." -
Print
"Updated inventory:"and the final inventory.
Make sure all messages match exactly.
Solution
Thanks for your feedback!
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat