# Rainfall Calculator # by Robert Layton print 'RAINFALL CALCULATOR' # Get input years = input('Please enter the number of years: ') totalRainfall = 0.0 #value to add to every month for total rainfall calculation #iterate over every month per year, getting the rainfall from the user for that month for year in range(1,years+1): for month in range(1,13): totalRainfall += input('\nEnter the rainfall for year ' + str(year) +', month ' + str(month) + ': ') #print results print '\n\nRAINFALL RESULTS' print 'Number of months:',years*12 print 'Total Rainfall:',totalRainfall print 'Average Rainfall per month:',totalRainfall/(years*12)
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