#Average Rainfall Years = int(raw_input( " How many years of rainfall data are we analyzing today? ")) print() Months = Years * 12 for nextYear in range(1,Years+1): for nextMonth in range (1,13): monthlyRainfall = int(raw_input( " How many inches of rainfall did you record in month {}? ".format(nextMonth))) totalRainfall=0 totalRainfall = totalRainfall+monthlyRainfall averageRainfall = totalRainfall/Months print( " We looked at {} months of rainfall data ".format(Months)) print( " During this time, {} inches of rainfall were recorded".format(totalRainfall)) print( " The average rainfall per month during this period was {}".format(averageRainfall))
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