In Python Using read file and process numbers The list of numbers below represen
ID: 3918092 • Letter: I
Question
In Python
Using read file and process numbers
The list of numbers below represents a txt file (test.txt)
-10.923
-6.11
-7.2934
-8.41
-9.5
-7.8111
-2.534
-6.912
-7.93456
-2.222
-5.432
-7.111
-9.324
-5.43
-7.83
-9.284
-7.1134
-9.234
-7.2134
-8.454
-1.2345
-9.231
All values are greater than 0 and less than 100.
Read in the file represented above (test.txt) and find the following:
-largest number
-smallest number
-total of all the numbers in the file.
Print the three numbers on a single line using the following format:
-print(“largest:%d smallest: %d total: %10.2f”%(largest,smallest,total)
Thank you for your assistance in advance.
Explanation / Answer
largest = 0 smallest = 100 total = 0 with open('test.txt', 'r') as f: for line in f: num = float(line.strip()) if num > largest: largest = num if numRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.