Skip to content

Instantly share code, notes, and snippets.

@alexperrone
Created June 26, 2014 01:16
Show Gist options
  • Save alexperrone/2bcf7ca98586f41314d5 to your computer and use it in GitHub Desktop.
Save alexperrone/2bcf7ca98586f41314d5 to your computer and use it in GitHub Desktop.
grade
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