Question: Define main function:data = getDatatotals, averages = calculate ( data ) printinfo ( data , totals,averages ) Define getData ( ) function :Here is Python

Define main function:data = getDatatotals, averages = calculate(data)printinfo(data, totals,averages)Define getData() function :Here is Python code that can used :rainfalldata =0]with open("rainfall.txt") as textFile:for line in textFile:city_info =[item.strip() for item in line.split(,)]rainfalldata.append(city_info)Define calculate(data) function :Define a 12-element list named totalsUse a nested for loop to loop through each row of the 2-dimensional list and calculate the sum of all the 12 rainfall columns and place each sum totals list. Be sure to start summing in with the second element because the first element of each row contains the city nameDefine a 13-element list named averages.Use a nested for loop to loop through each column of the 2-dimensional list and calculate the sum of all the rainfall rows. Calculate the average for the column. Store the average in the averages list. Be sure to start storing in the second element.return totals, averagesDefine printInfo(data,totals,averages) function :Output the first heading lineOutput the Time (hour) heading lineUse a nested for loop to loop through each row of the 2-dimensional data list:- Print the first element in the row (the city name)- Loop through all the columns printing out the rainfall amounts (use end="")--- Print the total list element for the row- Output the average line of the report:-- Output the label ("average")- Output the Highest Rainfall line.

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 Programming Questions!