Question: Write a program that allows the user to enter the total rainfall for each of 12 months into a list. The program should calculate and
Write a program that allows the user to enter the total rainfall for each of 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.
Data:
January 7.9 inches
February 10.1 inches
March 3.4 inches
April 6.7 inches
May 8.9 inches
June 9.4 inches
July 5.9 inches
August 4.1 inches
September 3.7 inches
October 5.1 inches
November 7.2 inches
December 8.3 inches
Code is not working.
Rainfall = list() # Defining the rainfall as list Month = ['January','February','March','April','May','June','July','August','September','October','November','December']; for i in Month: # For each value in month, append rainfall in Rainfall list print 'Enter Rain fall in inches for the month:',i Rainfall.append(float(raw_input()))
T = sum(Rainfall) # sum function calculates the total of rainfall print "Total rainfall in the year is : ",T A= T/12 print "Average rainfall in the Month is : ",A
for i in range(12): if(Rainfall[i]==max(Rainfall)): # max return higest rainfall value print Month[i],"Has the highest rainfall amount :" , Rainfall[i],"inches" if(Rainfall[i]==min(Rainfall)): # min returns lowest rainfall value print Month[i],"Has the Lowest rainfall amount :" , Rainfall[i],"inches"
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
