#Isaac Martinotti #CIS 122 #Week 4 Rainfall Assignment def main(): #Gather Input and Set Variables years = input('Please enter the numbers of years worth of data:') totalRainfall = 0 #Yearly Loop for annual in range(1,(years+1)): #Monthly Loop for month in range(1,13): newRainfall = input('Please enter the rainfall for month {} of year {}:'.format(month,annual)) totalRainfall = newRainfall + totalRainfall #Print Answers print print 'The total number of months is {}.'.format(years*12) print print 'The total amount of rainfall is: {}'.format(totalRainfall) print print 'The average rainfall per month is: {}'.format(totalRainfall/(years*12)) main()
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