Question: Write a program that uses nested loops to collect data and calculate the average rainfall over a period of years. The program should first ask

Write a program that uses nested loops to collect data and calculate the average rainfall over a period of years. The program should first ask for the number of years. The outer loop will iterate once for each year. The inner loop will iterate twelve times, once for each month. Each iteration of the inner loop will ask the user for the inches of rainfall for that month. After all iterations, the program should display the number of months, the total inches of rainfall, and the average rainfall per month for the entire period. Format the precision of total and average rainfall to 2 . If the user enters less than 1 for the number of years, the program should display an invalid input message and stop. If the users enters a negative number for the rainfall of a month, the program should display an invalid input message, and ask for the rainfall for that month again until a non-negative value is entered. Test your program with the data in Table 1. Finally, format your program to match the sample terminal. Your output should exactly match the sample output, character for character, including all white space and punctuation. User input in the sample has been highlighted in Pappy's Purple to distinguish it from the program's output, but your user input does not need to be colored. Save your program as rainfall_login.py, where login is your Purdue login. Then submit it along with a screenshot showing a run of all 3 test cases. Table 1: Rainfall test data. Terminal \$ python rainfall_login.py Enter the number of years: 0 Invalid input; years must be greater than 0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
