Respuesta :

Answer:

In python:

file = open("rates.csv", "r")

ratecount = 0

ratesum = 0

mylist = []

rates = file.readlines()

for nums in rates:

     num = nums.rstrip('\n')

     mylist.append(int(num))

     for i in num:

           ratesum= ratesum + int(i)

           ratecount = ratecount + 1

print("Maximum Rate: "+str(max(mylist)))

print("Minimum Rate: "+str(min(mylist)))

print("Average Rate: "+str(ratesum/ratecount))

Explanation:

This opens the csv file

file = open("rates.csv", "r")

This initializes the number of rates in the file

ratecount = 0

This initializes the sum of the rates

ratesum = 0

This initializes an empty list

mylist = []

This reads the rates into lines

rates = file.readlines()

This iterates through the rates (as a string)

for nums in rates:

This removes the newline character \n in the rates

     num = nums.rstrip('\n')

This appends the rates (as an integer) to the empty list

     mylist.append(int(num))

The following counts the rates in the file and also sum them up

     for i in num:

           ratesum= ratesum + int(i)

           ratecount = ratecount + 1

This prints the maximum of the rates

print("Maximum Rate: "+str(max(mylist)))

This prints the minimum of the rates

print("Minimum Rate: "+str(min(mylist)))

This calculates and prints the average rate

print("Average Rate: "+str(ratesum/ratecount))

ACCESS MORE