#Melissa Hensley #CIS 122 #Chapter 5 Exercise 6 #Average Rainfall months = 12 rainfall = [] y = input("How many years did it rain? ") print y for years in range(1, y + 1): for months in range(1,13): rain=input("How many inches did it rain for the month?") print rain total_time = y + months print("Total months of rainfall: " + str(y+months)) print("Total inches of rainfall: " + str(sum(rain+months))) print("Average inches of rainfall per month: " + str(sum(rain) / total_time))
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question