I am trying to figure out some homework for an intro to programming class. It seems I have gone the long way around finding most of the info. I have to design a program that takes a user input for total rainfall for each of the 12 months. It should calculate and display the total rainfall for the year, average rainfall, and the months with the highest and lowest amounts. I can get my program to do everything but display the month name with the highest and lowest. Like I mentioned before I know I have taken the long way on this and it is more than likely not the most efficient path. Here is my code.
year=[]
jan=float(input('Please enter Jan rainfall: '))
feb=float(input('Please enter Feb rainfall: '))
mar=float(input('Please enter Mar rainfall: '))
apr=float(input('Please enter Apr rainfall: '))
may=float(input('Please enter May rainfall: '))
jun=float(input('Please enter Jun rainfall: '))
jul=float(input('Please enter Jul rainfall: '))
aug=float(input('Please enter Aug rainfall: '))
sep=float(input('Please enter Sep rainfall: '))
oct=float(input('Please enter Oct rainfall: '))
nov=float(input('Please enter Nov rainfall: '))
dec=float(input('Please enter Dec rainfall: '))
year.extend((jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec))
def lowest():
print('The minimum rainfall is', min(year))
lowest()
def highest():
print('The most rainfall is', max(year))
highest()
def total():
print('The total rainfall is', sum(year))
total()
def average():
print('The average rainfall is', float(sum(year))/len(year))
average()
When I do this I get my input prompts, the min, the max, the total, and the average. I'm just not sure where to get the month names for the min and max. If there is a quicker way I'm all for it as well. Thanks.