Question
write code that reads and analyses prices from a text file. Firstly, you must read all of the prices from the file. Code which opens
write code that reads and analyses prices from a text file.
Firstly, you must read all of the prices from the file. Code which opens the file has been provided for you. Write code which reads from the file object prices_file, populating a list of numbers representing the prices that came from the file. Give your list variable an appropriate name.
Hint: you do not need to remove the trailing newline character from each line.
b) Analysing the prices
Next, you must write code which finds the the average price of items priced at $125 or more and find the the number of items that are prices below or above average price. You are to perform these computations by aggregating your list with a loop---do not use existing functions/methods like len, min, sum, or sort. Display the computed values to two decimal places using f-strings. Refer to the last part of Topic 4 for simple examples of aggregation using a loop.
You may assume that no item is priced $9999 or more.
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