print "Welcome to Cayleigh's Average Rainfall Program!" #greeting x = input("Enter the number of years: ") #asks for number of years print x #print number of years sum = 0 #introduce sum for y in range (x): #for y in range (amount of years) for z in range (1, 13): #for z in range (1, 13) which is for the amount of months in a year (12) a = input("Enter the rainfall amount in inches: ") #asks for input print a #prints input sum = sum + a #equation to add all of the inches together else: #when the loop is done b = x * 12 print "The total amount of months was: " + str(b) + " months." print "The total inches of rainfall was: " + str(sum) + " inches." c = float(sum) / float(b) print "The average rainfall per month during this period was: " + str(c) + " inches."
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