Write code to read the content of the text file input.txt. For each line in input.txt,...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write code to read the content of the text file input.txt. For each line in input.txt, write a new line in the new text file output.txt that computes the answer to some operation on a list of numbers. ⚫ If the input.txt has the following: Min: 1,2,3,5,6 Max: 1,2,3,5,6 Avg: 1,2,3,5,6 Your program should generate output.txt as follows. The min [1, 2, 3, 5, 6] is 1. The max of [1, 2, 3, 5, 6) is 6. The avg of (1, 2, 3, 5, 6] is 3.4. Assume that the only operations given in the input file are min, max and avg and that a list of comma-separated integers always follows the operation. You should define the functions min, max and avg that take in a list of integers and return the min, max or avg of the list. Your program should handle any combination of operations and any length of input numbers. You can assume that the list of input numbers are always valid integers and that the list is never empty. Compile, save and run your file. Write code to read the content of the text file input.txt. For each line in input.txt, write a new line in the new text file output.txt that computes the answer to some operation on a list of numbers. ⚫ If the input.txt has the following: Min: 1,2,3,5,6 Max: 1,2,3,5,6 Avg: 1,2,3,5,6 Your program should generate output.txt as follows. The min [1, 2, 3, 5, 6] is 1. The max of [1, 2, 3, 5, 6) is 6. The avg of (1, 2, 3, 5, 6] is 3.4. Assume that the only operations given in the input file are min, max and avg and that a list of comma-separated integers always follows the operation. You should define the functions min, max and avg that take in a list of integers and return the min, max or avg of the list. Your program should handle any combination of operations and any length of input numbers. You can assume that the list of input numbers are always valid integers and that the list is never empty. Compile, save and run your file.
Expert Answer:
Answer rating: 100% (QA)
Answer Below is a Python code that reads the content of the inputtxt file performs operations min m... View the full answer
Related Book For
Database Systems Design Implementation and Management
ISBN: 978-1285196145
11th edition
Authors: Carlos Coronel, Steven Morris
Posted Date:
Students also viewed these programming questions
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
You are developing an industrial building with a gross building area of 150,000 sf. The building efficiency ratio is 75%. The market gross rent is $25 psf. The vacancy rate is 5%; the cap rate is 5%;...
-
A right handed curve on a two way road has its BC at Ch 1420 and its EC at Ch 1680. The superelevation rate is 0,06 m/m and the superelevation development (run-off) length is 60 m. The center line of...
-
The accounting equation includes three basic types of accounts: assets, liabilities, and stockholders equity. In turn, stockholders equity holds the following types: common stock, retained earnings,...
-
Use the closeness ratings given after the activity (CloseAfter) to estimate the difference in mean rating of closeness between those who have just done a synchronized activity and those who do a...
-
United Furniture buys reclining rocking chairs at $550 less 40% and 10%. The price is marked up to allow for overhead of 50% of cost and profit of 35% of cost. The unit on display in the store...
-
The David Derrick Insurance company wants to sells a certain policy for $1000 to John Graham Jr. They know from historic data that there is a 1 in 100 chance John will file a $20,000 claim, a 1 in...
-
Telstar uses job order costing. The T-accounts below summarize its production activity for the year. 1. Compute the amount for each of the following. a. Direct materials used b. Indirect materials...
-
Solve the equation and check your solution. 6[4y 2(y-1)] 2 + 7y = 0
-
) Portfolio (Narrative) Students are required to create a children's story centered around a narrative from the visual, aural, haptic and kinaesthetic perspective of a child. The narrative should be...
-
Criminal justice organizations must be able to grow and change to improve and to meet the needs of a changing society. Effective organizational management can help facilitate the change process. In...
-
What is your insights about this?? COLLEGE VISION The College of Business Administration is envisioned to enhance the quality of life of a diverse population of students by enabling them to become...
-
I have to fill in each column for a child with behaviour issues. He is unable to express his needs and tends to hit friends when he wants something. I need an example for each column. The child is...
-
How can we mitigate the negative impacts of the grapevine in criminal justice organizations? Are there potential benefits to its presence in such organizations? Explain.
-
2. Two objects , B1 (T 40C) and B2 (T= 18C, experienced entropy changes of 6.4 x 10 J/K and 2.8 x 10 J/K, respectively, after they had been placed in direct contact with each other. Bi lost 2.0 x 10'...
-
Use the information given about the angles and to find the exact value of: (a) sin( + ) (b) cos( + ) (c) sin( - ) (d) tan ( + ) (e) sin(2) (f) cos (2) (g) sin /2 (h) cos/2 cos = 4/5, 0 < < /2; cos =...
-
Using Table as an example, create two alternative access plans.
-
How does a BASE system differ from a traditional distributed database system?
-
What problem would you encounter if you wanted to produce a listing by city? How would you solve this problem by altering the filestructure? PROJECT CODE PROJECT MANAGER MANAGER PHONE 21-52 25-2D...
-
What is the role of the origin of transfer during conjugation involving F+ and Hfr strains? What is the significance of the direction of transfer in Hfr conjugation?
-
What is the role of sex pili during conjugation?
-
Think about the structure and transmission of F factors, and discuss how you think F factors may have originated.
Study smarter with the SolutionInn App