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

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

1 Expert Approved Answer
Step: 1 Unlock

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... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!