askYear = int(raw_input("How many years would you like to see?")) print year = 0 month = 0 totalMonth = 0 totalInches = 0 totalMonth = 0 for year in range(1, askYear + 1): for month in range(1, 13): inchMonth = float(raw_input("What was the inches of rainfall this month?")) print totalInches = totalInches + inchMonth print("In month {} there were {} inches of rain".format(month,inchMonth)) totalMonth = totalMonth + 1 totalMonth = 12 * year aveMonth = totalInches/totalMonth print("In {} year(s), or {} months, there were {} inches of rainfall total and {} inches of rainfall on average".format(year, totalMonth,totalInches, aveMonth))
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