# Program calculates average the amount of rainfall per month in a given period of years # Written by Tuan Nguyen # 4/23/15 year = input("How many year(s) of data is collected? ") time = 0 totalInchesOfRain = 0 while time < year: for month in range(1,13): inchesOfRain = input("Enter the inches of rainfall for this month: ") totalInchesOfRain = totalInchesOfRain + inchesOfRain time = time + 1 totalMonths = year * 12 averageRain = totalInchesOfRain / totalMonths print("Number of months: {}".format(totalMonths)) print("Total inches of rainfall: {}".format(totalInchesOfRain)) print("Average rainfall per month: {}".format(averageRain))
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