Created
June 26, 2014 01:16
-
-
Save alexperrone/2bcf7ca98586f41314d5 to your computer and use it in GitHub Desktop.
grade
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
def main(): | |
grade = input('Please enter a grade between 0-100, 999 to exit. ') | |
while grade <> 999: | |
validatedGrade = validate(grade) | |
displayGrade(validatedGrade) | |
grade = input('Please enter a grade between 0-100, 999 to exit. ') | |
def validate(grade): | |
while grade < 0 or grade > 100: | |
print 'ERROR: Grade must be between 0-100.' | |
grade = input('Please enter a grade between 0-100, 999 to exit. ') | |
else: | |
print 'Thank you.' | |
return grade | |
def displayGrade(validatedGrade): | |
if validatedGrade < 60: | |
print 'Fail' | |
else: | |
print 'Pass' | |
grade = 'y' | |
while True: | |
grade = raw_input('Would you like to enter another grade? [y/n]') | |
if grade == 'y': | |
return grade | |
if grade == 'n': | |
print 'Okay. Thank you for using this program!' | |
sys.exit() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment