Challenge: Pricing Adjustment Capstone
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
Manage a grocery inventory using a dictionary. You will do three simple things: update one price, add one new item, and restock one item. Print short status messages so you can see what changed.
-
Create the Dictionary Define
grocery_inventorywith these items and details (category, price, stock):"Milk":("Dairy", 3.50, 8)"Eggs":("Dairy", 5.50, 30)"Bread":("Bakery", 2.99, 15)
-
Discount Eggs
- If the price of
"Eggs"is greater than5, print:Eggs are too expensive, reducing the price by $1.and reduce the price by1.
- If the price of
-
Add a New Item
- Add
"Tomatoes"with details:("Produce", 1.20, 30) - Print:
Inventory after adding Tomatoes: <grocery_inventory>
- Add
-
Restock Milk
- If the stock of
"Milk"is less than10, print:Milk needs to be restocked. Increasing stock by 20 units.and increase the stock by20.
- If the stock of
-
Final Print
- Print:
Updated inventory: <grocery_inventory>
- Print:
Solution
Thanks for your feedback!
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Awesome!
Completion rate improved to 1.89
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
Manage a grocery inventory using a dictionary. You will do three simple things: update one price, add one new item, and restock one item. Print short status messages so you can see what changed.
-
Create the Dictionary Define
grocery_inventorywith these items and details (category, price, stock):"Milk":("Dairy", 3.50, 8)"Eggs":("Dairy", 5.50, 30)"Bread":("Bakery", 2.99, 15)
-
Discount Eggs
- If the price of
"Eggs"is greater than5, print:Eggs are too expensive, reducing the price by $1.and reduce the price by1.
- If the price of
-
Add a New Item
- Add
"Tomatoes"with details:("Produce", 1.20, 30) - Print:
Inventory after adding Tomatoes: <grocery_inventory>
- Add
-
Restock Milk
- If the stock of
"Milk"is less than10, print:Milk needs to be restocked. Increasing stock by 20 units.and increase the stock by20.
- If the stock of
-
Final Print
- Print:
Updated inventory: <grocery_inventory>
- Print:
Solution
Thanks for your feedback!
single