Westonci.ca offers quick and accurate answers to your questions. Join our community and get the insights you need today. Experience the convenience of getting reliable answers to your questions from a vast network of knowledgeable experts. Discover detailed answers to your questions from a wide network of experts on our comprehensive Q&A platform.
Sagot :
Answer:
In Python:
year = int(input("Years: "))
while year<1:
year = int(input("Invalid. Enter 1 or greater: "))
total = 0
for i in range(1,year+1):
for j in range(1,13):
month = int(input("Year "+str(i)+", Month "+str(j)+": "))
while month<0:
month = int(input("Invalid. Enter 0 or greater: "))
total+=month
ave = total/(12*year)
print("Months: "+str(12 * year))
print("Total: "+str(total))
print("Average: "+str(ave))
Explanation:
This gets the number of years
year = int(input("Years: "))
This loop validates the number of years
while year<1:
year = int(input("Invalid. Enter 1 or greater: "))
This initializes total to 0
total = 0
This iterates through the years
for i in range(1,year+1):
This iterates through the month of each year
for j in range(1,13):
This gets the rainfall for each month
month = int(input("Year "+str(i)+", Month "+str(j)+": "))
This loop validates the amount of rainfall
while month<0:
month = int(input("Invalid. Enter 0 or greater: "))
This calculates the total rainfall
total+=month
This calculates the average rainfall
ave = total/(12*year)
This prints the number of month
print("Months: "+str(12 * year))
This prints the calculated total amount of rainfall
print("Total: "+str(total))
This prints the calculated average amount of rainfall
print("Average: "+str(ave))
We hope our answers were helpful. Return anytime for more information and answers to any other questions you may have. Thank you for visiting. Our goal is to provide the most accurate answers for all your informational needs. Come back soon. Stay curious and keep coming back to Westonci.ca for answers to all your burning questions.