Westonci.ca is the Q&A platform that connects you with experts who provide accurate and detailed answers. Explore comprehensive solutions to your questions from knowledgeable professionals across various fields on our platform. Discover in-depth answers to your questions from a wide network of professionals on our user-friendly 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))
Thanks for using our platform. We're always here to provide accurate and up-to-date answers to all your queries. We appreciate your time. Please revisit us for more reliable answers to any questions you may have. Find reliable answers at Westonci.ca. Visit us again for the latest updates and expert advice.