Skip to content

Instantly share code, notes, and snippets.

@noncreature0714
Last active November 3, 2016 23:51
Show Gist options
  • Save noncreature0714/f8f1288252db28992f35ff44af535f3f to your computer and use it in GitHub Desktop.
Save noncreature0714/f8f1288252db28992f35ff44af535f3f to your computer and use it in GitHub Desktop.
vassLab6
class ValueNotInRange(Exception):
def __init__(self):
super(ValueNotInRange, self).__init__()
pass
STUDENTS = 3
def stuLog():
try:
outfile = open('grades.txt', 'w')
except OSError as err:
print(err)
for x in range(STUDENTS):
studentName = input('enter student name: ')
try:
studentGrade = int(input('enter sutdents grade: '))
except ValueError as err:
print(err)
answer = "lkjlkjk"
while(not answer.isdigit()):
answer = input("Please enter an integer value: ")
studentGrade = int(answer)
try:
if studentGrade < 0 or studentGrade > 100:
raise ValueNotInRange
except ValueNotInRange:
print ("Please enter a value 1-100: ")
answer = -1
while(answer < 0 or answer > 100):
answer = int(input())
outfile.write(studentName + '\t')
outfile.write(str(studentGrade) + '\n')
outfile.close()
inFile = open('grades.txt', 'r')
for line in inFile:
print(line)
print("Hello")
stuLog()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment