#Josh Roybal #CIS 122 #Chapter 5 Programming Exercise #7 totalYears = 0 yearsPassed = 1 month = 1 totalMonths = 0 monthlyRainfall = 0 totalRainfall = 0 averageRainfall = 0 totalYears = int(input("Please enter the total number of years tracked: ")) while yearsPassed <= totalYears: print('Year', yearsPassed, ': \n') while month <= 12: print('Please enter the amount of rainfall in inches for month', month, ':') monthlyRainfall = int(input(" ")) totalRainfall += monthlyRainfall month += 1 yearsPassed += 1 month = 1 totalMonths = totalYears * 12 averageRainfall = totalRainfall / totalMonths print('The average rainfall for a total of', totalMonths, 'months is:', averageRainfall, '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