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 steps in order:

  1. Create the grocery_inventory dictionary using the table above. Each value should be a tuple: (category, price, stock).

  2. Check "Eggs" price. If it exceeds $5, reduce it by $1 and print "Eggs are too expensive, reducing the price by $1." Otherwise, print "The price of Eggs is reasonable."

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

  4. Store the current "Milk" stock in a variable named milk_stock. If it 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. If "Apples" price exceeds $2, remove it and print "Apples removed from inventory due to high price."

  6. Print "Updated inventory:" and the final inventory.

Make sure all messages match exactly.

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