Question: In Python programming, I want to use the min/max function to get the minimum and maximum rainfall, to include the related month. I have posted

In Python programming, I want to use the min/max function to get the minimum and maximum rainfall, to include the related month. I have posted my code that I am working on, and everything works up to the "low = (min(rainFall))" line.

##Write a program that allows the user to enter the total rainfall for each ##of the 12 months into a list. The program should calculate and display ##the total rainfall for the year, the average monthly rainfall, and the months ##with the highest and lowest rainfall amounts.

def main(): months = ['January', 'February' , 'March' , 'April' , 'May', 'June', 'July',\ 'August' , 'September', 'October', 'November', 'December']

total = 0

for months in list(months): newList = [] rainFall = float(input("Enter the total monthly rainfall in inches: ")) newList.append(rainFall)

for values in list(newList): total += rainFall print(months, rainFall) print() print("Updated rainfall total for the year:" ,format(total, '.3f')) average = total / 12 print("The average rainfall for the year is" ,format(average, '.3f'))

low = (min(rainFall) month = months[rainFall.index(low)] print(low) #print(max(rainFall))

## newList.index(min(newList)) ## months.index(min(months)) ## minRainfall = newList.index(min(newList)) ## indexMinMonth = newList.index(min(newList)) ## print(min(newList)) ## maxRainfall = max(newList) ## indexMaxMonth = newList.index(max(newList)) ## print(max(newList)) main()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!