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)
Based on the images you shared it seems youre looking for Python functions that will allow you to manage the inventory of products in a stock manageme... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
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...
-
Examine the resources that were critical in getting the company off the ground
-
Lori just bought a new set of four tires for her car. The life of each tire is normally distributed with a mean of 45,000 miles and a standard deviation of 2000 miles. Find the probability that all...
-
The force exerted by expanding gases is what propels a shell out of a gun barrel. Suppose a force that has an average magnitude \(F\) propels the shell so that it has a speed \(v\) at the instant it...
-
It is estimated that over 100,000 students will apply to the top 30 M. B. A. programs in the United States this year. a. Using the concept of net present value and opportunity cost, explain when it...
-
On January 1, 2024, the Allegheny Corporation purchased equipment for $134,000. The estimated service life of the equipment is 10 years and the estimated residual value is $2,000. The equipment is...
-
3.2 A design team is conducting a trade study of recovery options for a rocket-launched high-speed battlefield reconnaissance system. The mission radius is 400 n miles with 1-h time on station. The...
-
The dwarf planet Pluto has an orbit with semimajor axis 5 . 9 1 x 1 0 ^ 1 2 m and eccentricity 0 . 2 4 9 . Find the perihelion and aphelion distances for Pluto. Compare both distances you found with...
-
both included in the $4,780 included on the Profit & Loss Statement. How do Imputation Credits affect Tax Payable/Refund in your tax reconciliation for Bend-It Physio?
-
How is the Standard Deviation and Coefficient of Variation calculated in this table.
-
What role does digital media play in defamiliarizing cultural diversity by providing platforms for underrepresented voices to be heard, and what challenges do these efforts face in terms of...
-
Target price is $120 and has 20% expected return. What is the per unit target sales revenue?
-
Create a public functional interface Validate with a method: public boolean validate name(String name); Create a public class ValidateUtility with the below methods: public static Validate...
-
a) Show that (a, b) := {{a}, {b}} does not satisfy the ordered pair axiom. b) Determine whether each of the following statements is true or false. (Give a reason in each case): (i) {a, b} C (a, b)....
-
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...
-
Resource leveling is a method to: a. Make sure everyone working on the project has approximately the same amount of work to accomplish b. A technique in which start and finish dates are adjusted...
-
Resources should be estimated against which entity: a. The deliverables level of the WBS b. Critical project constraints c. The Risk Breakdown Structure d. The schedule activities
-
When are the resource requirements estimated? a. After the activities have been defined but before the schedule has been developed b. After the schedule has been developed but before the activities...
Study smarter with the SolutionInn App