def calcAverage (num1, num2, num3, num4, num5): avg = (num1+num2+num3+num4+num5) / 5 return float(avg) def determineGrade(average): lettergrade = "" if average >= 90: lettergrade = "A" elif average >= 80 and average <= 89: lettergrade = "B" elif average >= 70 and average <= 79: lettergrade = "C" elif average >= 60 and average <= 69: lettergrade = "D" else: lettergrade = "F" return lettergrade num1 = input('Please enter a score: ') print num1 num2 = input('Please enter a score: ') print num2 num3 = input('Please enter a score: ') print num3 num4 = input('Please enter a score: ') print num4 num5 = input('Please enter a score: ') print num5 average = calcAverage(num1, num2, num3, num4, num5) letter = determineGrade(average) print 'The average for these grades is ', average print 'The letter grade for these assignments will be an:', letter
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