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 calculatedataprintinfodata totals,averagesDefine getData function :Here is Python code that can used :rainfalldata with openrainfalltxt as textFile:for line in textFile:cityinfo itemstrip for item in line.splitrainfalldataappendcityinfoDefine calculatedata function :Define a element list named totalsUse a nested for loop to loop through each row of the dimensional list and calculate the sum of all the 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 element list named averages.Use a nested for loop to loop through each column of the 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 printInfodatatotals,averages function :Output the first heading lineOutput the Time hour heading lineUse a nested for loop to loop through each row of the 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
