Question
Write a Python program that creates a class which represents an ProductList (of specific Products-example phones) in an organization. The class includes a function that
Write a Python program that creates a class which represents an ProductList (of specific Products-example phones) in an organization. The class includes a function that reads a text file called productdetails.txt (A sample of the file is provided below) Each row in the file corresponds to productcode, productName, quantity and price. a. getProduct(): This method reads the data from a file and stores the products as a list.
b. totalCost(): This method calculates the total cost for each product. The method should calculatethe total price based on the quantity.
c. highestCost() and lowestCost(): These methods calculate the highest and lowest cost anddisplay the respective product names.
d. sortProductbycost(): Sort the product list in the ascending order of their costs.
F.run it and get a screenshot of the output
Also include the following functions to process the content read from the file.
Sample input file: productdetails.txt
productcode | productName | quantity | price |
S0011 | Nokia | 9 | 4500 |
S0012 | Samsung | 3 | 17000 |
S0013 | iPhone | 2 | 26770 |
S0014 | Macbook Pro | 5 | 8700 |
S0015 | HP Laptop | 1 | 5000 |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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