Design an interactive product management system using Python function. In the stock.txt file, there are product...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 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
Expert Answer:
Answer rating: 100% (QA)
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 the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Marvel Parts Inc. manufactures auto accessories. One of the company's products is a set of seat covers that can be adjusted to fit nearly any small car. The company has a standard cost system in use...
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
can someone solve this Modern workstations typically have memory systems that incorporate two or three levels of caching. Explain why they are designed like this. [4 marks] In order to investigate...
-
a1a2 (d) Suppose a Cobb Douglass production function with two inputs and exponents inside the production function y = xx22 that are less than one. Derive the profit maximizing choices of x1, x2, andy...
-
Argon gas expands in an adiabatic turbine from 3 MPa and 750C to 0.2 MPa at a rate of 5 kg/s. The maximum power output of the turbine is (a) 1.06 MW (b) 1.29 MW (c) 1.43 MW (d) 1.76 MW (e) 2.08 MW
-
Were any problems unforeseeable?
-
Which of the following statements is false? a. Transactions are frequently analyzed using a T-account. b. All T-accounts have both a debit and a credit side. c. The left side of a T-account is called...
-
Wickliffe County authorized the issuance of bonds and contracted with the USA Construction Company (UCC) to build a new sports complex. During 2014, 2015, and 2016 the county engaged in the...
-
Current Attempt in Progress Condensed financial data of Sage Hill Inc. follow. \ table [ [ \ table [ [ Sage Hill Inc. ] , [ Comparative Balance Sheets ] , [ December 3 1 ] ] ] , [ Assets , 2 0 2 5 ,...
-
Colt Company reports pretax financial income of $143,000 in 2019. In addition to pretax income from continuing operations (of which revenues are $295,000), the following items are included in this...
-
Describe the major functions of human resource management that are explored in the course. Illustrate your answer with an example of each function.
-
What information is provided by the Fixed Asset Managers Depreciation Schedule by G/L Account Number report?
-
Political pollsters may be interested in the proportion of people who will vote for a particular cause. identify: a. the population, b. the sample, c. the parameter, d. the statistic, e. the...
-
What is the population she is interested in? a. all Lake Tahoe Community College students b. all Lake Tahoe Community College English students c. all Lake Tahoe Community College students in her...
-
A politician is interested in the proportion of voters in his district who think he is doing a good job. identify: a. the population, b. the sample, c. the parameter, d. the statistic, e. the...
-
percent of body fat identify the type of data that would be used to describe a response (quantitative discrete, quantitative continuous, or qualitative), and give an example of the data.
-
Exercise 3-8 An employee in Manitoba has use of a company owned automobile for the entire 2018 year. The following information is available: Total cost of the vehicle: Days available to the employee:...
-
6. (Potential Energy and Conservation of Energy) What should be the spring constant k of a spring designed to bring a 1200-kg car to rest from a speed of 95 km/h so that the occupants undergo a...
-
Revisit Problem P16-3 where the RTD function is a hemicircle. The liquid-phase reaction is first order with k1 = 0.8 min 1 . What is the conversion predicted by a. The tanks-in-series model? b. The...
-
Redo Problem P9-17B (a), (c), and (d) using the Tessier equation r g = max [1 e Cs/k ]C c with max = 1.0 h1 and k = 8 g/dm3. Data from problem P9-17B (a), (c), and (d) a. The reaction is to be...
-
a. Example 17-2: Mean Conversion, Xseg, Calculations in a Real Reactor Wolfram and Python 1. How do C A0 , n and k affect the trajectories in X for the segregation model and the LFR? 2. Write a set...
-
Describe four indicators commonly used in operating indicator analysis.
-
What is the difference between financial and operating indicator analyses?
-
Talias Tutus bought a new sewing machine for $40,000 that will be depreciated using the MACRS depreciation schedule for a 5-year recovery period. a. Find the depreciation charge each year. b. If the...
Study smarter with the SolutionInn App