Question: In FlowChart Raptor Question: Average Rainfall Write a algorithm and Python program that uses nested loops to collect data and calculate the average rainfall over
In FlowChart Raptor
Question: Average Rainfall
Write a algorithm and Python program that uses nested loops to collect data and calculate the average rainfall over period of years.
1. The program has a function named getYear. The function asks the user to enter the number of years and return the number. Input validation is need for the year: do not accept negative number of years or 0 for years.
2. The program has a function named getRainFall. The function asks the user to enter the rainfall for a month and return that number. (Input validation: do not accept negative number for the rainfall)
3. The program has a function named calcAvgRain to calculate and return the average monthly rainfall over a period of years. It accepts the number of years as argument. The function uses a nested loop to collect the rainfall for those many 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 call the function defined in step 2 to get the rainfall of a month. Then that rainfall will be accumulated to the total rainfall. 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.
4. The main module calls the above functions in proper order
Question: Average Rainfall Write a algorithm and Python program that uses nested loops to collect data and calculate the average rainfall over period of years. 1. The program has a function named getYear. The function asks the user to enter the number of years and return the number. Input validation is need for the year: do not accept negative number of years or O for years. 2. The program has a function named getRainfall. The function asks the user to enter the rainfall for a month and return that number. (Input validation: do not accept negative number for the rainfall) 3. The program has a function named calcAvgRain to calculate and return the average monthly rainfall over a period of years. It accepts the number of years as argument. The function uses a nested loop to collect the rainfall for those many 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 call the function defined in step 2 to get the rainfall of a month. Then that rainfall will be accumulated to the total rainfall. 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. 4. The main module calls the above functions in proper order
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
