TotalYears=raw_input('Please enter the number of years') TotalYears=int(TotalYears) print(TotalYears) for year in range(1, TotalYears+1): TotalInches = 0 Month = 12 for time in range(1,Month+1): Inches=float(raw_input('Please enter the inches of rainfall for this month')) TotalInches = Inches + TotalInches print("Month {} had {} inches of rain. Total rainfall in inches so far is {} ".format(time,Inches,TotalInches)) totalMonths = TotalYears * time AvgRainfall = TotalInches / totalMonths print("Total rainfall for the period is {} inches and the total number of months worth of data is {}, \nwhich results in a monthly average for the period of {} inches.".format(TotalInches,totalMonths,AvgRainfall))
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