Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a Python file called amazon.py in your folder. Write code to read the content of the text file input.txt. For each line in input.txt,

Create a Python file called amazon.py in your folder.

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 of [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 the operation is always followed by a list of comma-separated integers.

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, so as not to have to write code to check for these cases.

Hint: there is something strange about the first line of input.txt.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Server T-SQL Recipes

Authors: David Dye, Jason Brimhall

4th Edition

1484200616, 9781484200612

More Books

Students also viewed these Databases questions