Welcome to Westonci.ca, the Q&A platform where your questions are met with detailed answers from experienced experts. Join our platform to connect with experts ready to provide precise answers to your questions in various areas. Connect with a community of professionals ready to provide precise solutions to your questions quickly and accurately.
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))
Your visit means a lot to us. Don't hesitate to return for more reliable answers to any questions you may have. We appreciate your time. Please revisit us for more reliable answers to any questions you may have. Stay curious and keep coming back to Westonci.ca for answers to all your burning questions.