Page 1 of 1

• 5. Modify the total.py program so that it also prints the largest and smallest values, not just the total and average.

Posted: Mon May 02, 2022 11:37 am
by answerhappygod
5 Modify The Total Py Program So That It Also Prints The Largest And Smallest Values Not Just The Total And Average 1
5 Modify The Total Py Program So That It Also Prints The Largest And Smallest Values Not Just The Total And Average 1 (119.87 KiB) Viewed 31 times
5 Modify The Total Py Program So That It Also Prints The Largest And Smallest Values Not Just The Total And Average 2
5 Modify The Total Py Program So That It Also Prints The Largest And Smallest Values Not Just The Total And Average 2 (257.01 KiB) Viewed 31 times
5 Modify The Total Py Program So That It Also Prints The Largest And Smallest Values Not Just The Total And Average 3
5 Modify The Total Py Program So That It Also Prints The Largest And Smallest Values Not Just The Total And Average 3 (178.52 KiB) Viewed 31 times
(python)modify the total.py program so that it also prints the largest and smallest values, not just the total and average. for example, the output for the sample input in section 7.1.4 would look as follows:
• 5. Modify the total.py program so that it also prints the largest and smallest values, not just the total and average. For example, the output for the sample input in Section 7.1.4 would look as follows: ما 32.00 54.00 67.50 29.00 35.00 80.25 115.00 Total: 412.75 Average: 58.96 Max: 115.00 Min: 29.00
= I = total2.py 1 ## 2 # This program reads a file containing numbers and writes the numbers to 3 # another file, lined up in a column and followed by their total and average. 4 # 5 6 # Prompt the user for the name of the input and output files. 7 inputFileName = input("Input file name: ") 8 outputFileName = input("Output file name: ") 9 10 # Open the input and output files. 11 infile = open(inputFileName, "r") 12 outfile = open(outputFileName, "w") 13 14 # Read the input and write the output. 15 total = 0.0 16 count = 0 17 18 line = infile.readline() 19 while line != " 20 value = float(line) 21 outfile.write("%15.2f\n" % value) 22 total = total + value 23 count = count + 1 24 line = infile.readline(). 25 26 # Output the total and average. 27 outfile.write("%15s\n" % = . 11 -")
perlampur cum, 12 outfile = open(outputFileName, "W") 13 14 # Read the input and write the output. 15 total = 0.0 16 count = 0 17 18 line = infile.readline() 19 while line != " 20 value = float(line) 21 outfile.write("%15.2f\n" % value) 22 total = total + value 23 Count = count + 1 24 line = infile.readline() 25 26 # Output the total and average. 27 outfile.write("415s\n" % -----") 28 outfile.write("Total: %8.2f\n" % total) 29 30 avg = total / count 31 outfile.write("Average: %6.2f\n" % avg) 32 33 # Close the files. 34 infile.close() 35 outfile.close() CodeCheck Reset