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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 21:30, mjweed2456
Nathan wants to create multiple worksheet containing common formatting styles for his team members. which file extension him to save these worksheets? nathan to create multiple worksheets with common styles. he needs to save them with the extension.
Answers: 1
image
Computers and Technology, 23.06.2019 07:30, devnnn44
What is the original authority for copyright laws
Answers: 1
image
Computers and Technology, 23.06.2019 18:30, aalyssag606
This program should be a short piece of code that prints all of the positive integers from 1 to 100 as described more fully below. the program may contain multiple methods, and if using an oo language, should be contained within a single class or object. the program should be designed so that it begins execution when invoked through whichever mechanism is most common for the implementation language. â–ş print out all positive integers from 1 to 100, inclusive and in order. â–ş print messages to standard output, matching the sample output below. â–ş in the output, state whether the each integer is 'odd' or 'even' in the output. â–ş if the number is divisible by three, instead of stating that the number is odd or even, state that the number is 'divisible by three'. â–ş if the number is divisible by both two and three, instead of saying that the number is odd, even or divisible by three; state that the number is 'divisible by two and three'. â–ş design the logic of the loop to be as efficient as possible, using the minimal number of operations to perform the required logic. sample output the number '1' is odd. the number '2' is even. the number '3' is divisible by three. the number '6' is divisible by two and three.
Answers: 1
image
Computers and Technology, 24.06.2019 09:10, daedae11142
  to change the number of rows and columns displayed by the excel object a. select the object and drag a size handle on the active object. b. deselect the object and drag a size handle of the object. c. deselect the object and drag a row or column divider of the object. d. select the object and drag a row or column divider on the active object.
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 in other subjects:

Konu
History, 10.11.2019 04:31
Konu
Mathematics, 10.11.2019 04:31