Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Design an interactive product management system using Python function. In the stock.txt file, there are product names and their corresponding stock numbers. coke, 10
Design an interactive product management system using Python function. In the stock.txt file, there are product names and their corresponding stock numbers. coke, 10 juice, 5 milk, 13 Import the stock.txt file and save the content into a dictionary named stock. (15pts) Example: {'coke': 10, 'milk': 13, juice': 5} 2. Write a function to generate overall stats for all products (15pts) Function name: gen_stats Parameters: stock dictionary Return: None 1. Description: Print all basic stats of all products, such as the total amount for all products, the average, the maximum and the minimum. 3. Write a function to calculate the amount of a given product (30pts) Function name: check_stock Parameters: Stock dictionary, product name Return: The number in stock for that product. Description: Retrieve the corresponding number in stock for a given product. The given product is obtained from the user (use input function). Your program should be able to handle the invalid case where the input is not in stock. Act Go Sample Run 1 Enter a product name: coke The number is: 10 Sample Run 2 Enter a product name: orange We don't have this product 4. Write a function to update the amount for a given product (40pts) Function name: update_stock Parameters: The stock dictionary, a given product, the number Return: The updated stock dictionary Description: Update the number in stock for a given product. The given product and the number are obtained from the user (use input function). Your program should be able to handle the invalid case where the input is not in stock. Sample Run 1 Enter a product name and a number: coke, 11 The updated dictionary is: {'coke': 11, 'milk': 13, 'juice': 5, ...} Sample Run 2 Enter a product name: orange, 11 We don't have this product
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Python program for the interactive product management system Please go through the comments to understand the lines of code 2 Write a function to generate overall stats for all the products def gensta...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started