Question: Design a program that lets the user enter the total rainfall for each of 12 months into a list. The program should calculate and display
Design a program that lets the user 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 amounts.
![1 def main): #De fine list of months months- namemonths = [0] * 12 3 4 (Jan,Feb , Mar,Apt,May,Jun, - Jul,Aug, Sep, Oct, Nov, Dec ] #Function for total number of month3 7 def total (months) 8 total=0 9 for num in months: 10 total+=num 11 return total 12 #amount of rain in each month 13 for index in range (12) 14 print Enter the amount of rain in, 15 months [index] input (name months [index] + : ) 16 print The total is, total (months), m 17 #average 18 avarage=total (months) / 12.0 19 print The avarage rainfall is, avarage, m 20 # fir3tly make an unsorted copy 21 m copy = months [0 : ] 22 #Sorting list 23 months.sort () 24 lowe 3 t=months [0] 25 print Lowest is, lowest, in 26 # we are going to make a 113t of the month names that 27 lows=[] 28 for i in range (12) 29 ifm copy [i]== lowest: 30 lows.append name months[i] ) 31 for i in range (len (lows)): 32 print lows [i], 33 if i len (lows)-1: print and, 34 print 35 highe3t= months [11] 36 print Highest is, highest, in, 37 # we are going to make a list of the month names that 38 highs lows et highe3t](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2022/08/6308d214c530a_4526308d21460800.jpg)

in in WNHO 10 000 UTA W N P P P P P P P P P P 1 def main (): #Define list of months 3 months = [0] * 12 4 name_months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] #Function for total number of months 5 8 total = 0. 9 for num in months: 10 total + num 11 return total 12 #amount of rain in each month 13 for index in range (12): 14 print 'Enter the amount of rain in', 15 months [index] input (name_months [index] + ': 16 print 'The total is', total (months), 17 #average 'mm. ' 18 avarage 6 NNNNNNNNNN 7 def total (months): UI total (months) / 12.0 19 print 'The avarage rainfall is', avarage, #firstly make an unsorted copy m_copy months [0] #Sorting list months.sort () months [0] 6000 20 684 WNHO 21 w w w w w 22 23 24 lowest 25 print 'Lowest is', lowest, 'in', 26 #we are going to make a list of the month names that = lowset 27 lows = [] 28 for i in range (12): 29 if m_copy[i] == lowest: 30 31 32 33 34 35 36 37 'mm. ' 38 lows.append( name_months[i]) for i in range (len (lows)) : print lows [1], if i 26 #we are going to make a list of the month names that = lowset 27 lows = [] for i in range (12): if m_copy[i] == lowest: 28 29 30 31 32 33 34 35 36 37 38 39 lows.append( name_months[i]) for i in range (len (lows)) : print lows [i], if i < len(lows) -1: print 'and', print highest = months [11] print 'Highest is', highest, 'in', #we are going to make a list of the month names that = highest highs = [] for i in range (12): if m_copy[i] == highest: 40 41 highs.append( name_months[i]) 42 for i in range (len (highs)) : 43 print highs[i], 44 if i < len(highs)-1: print 'and', 45 46 47 print main ()
Step by Step Solution
3.45 Rating (161 Votes )
There are 3 Steps involved in it
This script is designed to gather rainfall data calculate total and average rainfall and identify months with the highest and lowest rainfall However ... View full answer
Get step-by-step solutions from verified subject matter experts
