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

bookChallenge: 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.

Task

Swipe to start coding

Manage a grocery inventory using a dictionary in Python. Perform basic operations: update a price, add a new item, adjust stock based on a condition, optionally remove an item by price, and print simple status messages.

  1. Create the Dictionary
    Define grocery_inventory with the following items and details:

    • "Milk": ("Dairy", 3.50, 8)
    • "Eggs": ("Dairy", 5.50, 30)
    • "Bread": ("Bakery", 2.99, 15)
    • "Apples": ("Produce", 1.50, 50)
  2. Check and Update Price

    • Get the price of "Eggs".
    • If the price is greater than 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 a New Item

    • Add "Tomatoes" with details: category "Produce", price 1.20, stock 30.
    • Then print
      Inventory after adding Tomatoes: <grocery_inventory>
  4. Manage Stock

    • Check the stock of "Milk".
    • If it is less than 10, print
      Milk needs to be restocked. Increasing stock by 20 units.
      and increase the stock by 20.
    • Otherwise, print
      Milk has sufficient stock.
  5. Remove Item Based on Price

    • If the price of "Apples" exceeds 2, remove "Apples" and print
      Apples removed from inventory due to high price.
  6. Final Print

    • Print
      Updated inventory: <grocery_inventory>

Solution

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

Suggested prompts:

What criteria should I use to decide when to restock or remove items?

Can you help me set up a system to track inventory and prices?

How can I automate notifications for low stock or price changes?

close

Awesome!

Completion rate improved to 2.17

bookChallenge: 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

Manage a grocery inventory using a dictionary in Python. Perform basic operations: update a price, add a new item, adjust stock based on a condition, optionally remove an item by price, and print simple status messages.

  1. Create the Dictionary
    Define grocery_inventory with the following items and details:

    • "Milk": ("Dairy", 3.50, 8)
    • "Eggs": ("Dairy", 5.50, 30)
    • "Bread": ("Bakery", 2.99, 15)
    • "Apples": ("Produce", 1.50, 50)
  2. Check and Update Price

    • Get the price of "Eggs".
    • If the price is greater than 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 a New Item

    • Add "Tomatoes" with details: category "Produce", price 1.20, stock 30.
    • Then print
      Inventory after adding Tomatoes: <grocery_inventory>
  4. Manage Stock

    • Check the stock of "Milk".
    • If it is less than 10, print
      Milk needs to be restocked. Increasing stock by 20 units.
      and increase the stock by 20.
    • Otherwise, print
      Milk has sufficient stock.
  5. Remove Item Based on Price

    • If the price of "Apples" exceeds 2, remove "Apples" and print
      Apples removed from inventory due to high price.
  6. Final Print

    • Print
      Updated inventory: <grocery_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

some-alt