Question: Define a method / function randoms _ to _ file ( n , n 1 , n 2 , filename ) such that n random
Define a methodfunction randomstofilen n n filename such that n random
integers positive or negative in the range of n n are generated and will be written
to the file with the name of filename
Define a methodfunction readfileandprocess such that:
o Prompt for a filename of file to be opened for inputs, you need to use whileloop
with tryexcept in case of the incorrect input of the file name.
o Read in all the numbers on the file hints: you can only read in a string, so you
need to use int for conversion to integers
o A list of items is returned with items in this order in the list:
The minimum number in the file
The maximum number in the file
The number of integers in the file
The average of those numbers in the file
Hints: The largest integer is sysmaxsize the smallest is sysmaxsize
Implement a regular main function such that:
o Prompt for inputs of n n n filenamesee the above definitions for them. A
whileloop with tryexcept is required to make sure of the correct inputs!
o Call function randomstofile
o Call function readfileandprocess
o Print the outputs returned from the above call
o Hints: use the following demo execution samples to guide your design and
implementation of this project.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
