subject

Write a Python program (rainfall. py) to collect data and calculate the average rainfall over a period of years. The program should first ask for the number of years. Then for each year, the program should ask twelve times, once for each month, for inches of rainfall for that month. At the end, , the program should display the number of months, the total inches of rainfall, and the average rainfall per month for the entire period. Your program should contain two functions:

(1) rainfall(year): This function takes in a year (integer) as a parameter, and returns two values (totalMonths and totalRainfall). In this function, you need to use nested loop. 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 inches (float) of rainfall for that month. After all iterations, the function should return the number of months (totalMonths) and the total inches of rainfall (totalRainfall). (Submit for 4 points)

(2) __main__: In the main, you do the following: (Submit for 6 points)

a. Prompt the user to input the number of years. Reprompt the user if the number of years is 0 or less. Hint: use a while loop.
b. Call rainfall(year) and pass to it the value entered above.
c. Calculate the average based on the returned values from rainfall function.
d. Display the number of months, the total inches of rainfall, and the average rainfall per month for the entire period.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 18:00
Jenna updated her status on a social network regarding her upcoming vacation. what information should jenna not provide when updating her status on a social networking site? a. her favorite quote b. her likes in popular culture c. her routine d. her opinions on social issues res
Answers: 1
question
Computers and Technology, 22.06.2019 00:40
Reading characters and strings from the keyboard: consider the following c++ program 1. #include 2. #include 3. using namespace std; 4. mystring1 5. 6. int main() 7. { 8. 9. string mystring1, mystring2; mychar1 10. 11. 12. char mychar1, mychar2; 13. 14. cout< < "enter a string: "; mychar2 15. 16. cin> > mystring1; // 17. cin.get(mychar1); 18. cin> > mychar2; 19. getline(cin,mystring2); mystring2 20. 21. 22. cout<
Answers: 1
question
Computers and Technology, 22.06.2019 15:30
Why would a programmer use the logical operator and in an if statement? a: when an action is to be taken that requires both conditions to be falseb: when an action is to be taken that requires both conditions to be truec: when an action is to be taken that requires the first condition to be falsed: when an action is to be taken that requires the second condition to be truei took the test and the answer is b.
Answers: 3
question
Computers and Technology, 22.06.2019 18:00
Write a method named addall that could be placed inside the hashintset class. this method accepts another hashintset as a parameter and adds all elements from that set into the current set, if they are not already present. for example, if a set s1 contains [1, 2, 3] and another set s2 contains [1, 7, 3, 9], the call of s1.addall(s2); would change s1 to store [1, 2, 3, 7, 9] in some order. you are allowed to call methods on your set and/or the other set. do not modify the set passed in. this method should run in o(n) time where n is the number of elements in the parameter set passed in.
Answers: 2
You know the right answer?
Write a Python program (rainfall. py) to collect data and calculate the average rainfall over a peri...
Questions
question
Computers and Technology, 07.10.2019 13:30
question
Mathematics, 07.10.2019 13:30
question
History, 07.10.2019 13:30