In: Computer Science
In python please design a program that lets the user enter the total rainfall for each of the last 10 years into an array. The program should calculate and display the total rainfall for the decade, the average yearly rainfall, and the years with the highest and lowest amounts.
Should have
Thanks for the question. Below is the code you will be needing. Let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please rate the answer. Let me know for any help with any other questions. Thank You ! =========================================================================== rainfalls_list = [0] * 10 for i in range(len(rainfalls_list)): rainfall = float(input('Enter rainfall for year #{}: '.format(i + 1))) rainfalls_list[i]=rainfall total_rainfall = 0 min_rainfall = 0 max_rainfall = 0 for i in range(len(rainfalls_list)): total_rainfall += rainfalls_list[i] if rainfalls_list[i] < rainfalls_list[min_rainfall]: min_rainfall = i elif rainfalls_list[i] > rainfalls_list[max_rainfall]: max_rainfall = i print('Total Rainfall for the decade: {:.2f} mm'.format(total_rainfall)) print('Average Yearly Rainfall: {:.2f} mm'.format(total_rainfall / 10)) print('Year: {} has the lowest rainfall of {} mm'.format(min_rainfall + 1, rainfalls_list[min_rainfall])) print('Year: {} has the highest rainfall of {} mm'.format(max_rainfall + 1, rainfalls_list[max_rainfall]))
==================================================================