Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Pricing Adjustment Capstone | Other Data Types
Introduction to Python
Section 4. Chapter 8
single

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.

Task

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:

  1. Create the grocery_inventory dictionary using the data from the table above. Each value is a tuple of (category, price, stock).

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

  3. Add Tomatoes — category "Produce", price $1.20, stock 30. Then print the full inventory with the message "Inventory after adding Tomatoes:".

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

  5. Remove Apples — if the price exceeds $2, remove the item and print "Apples removed from inventory due to high price."

  6. Print the final inventory with the message "Updated inventory:".

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 4. Chapter 8
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

some-alt