-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrade_program.py
More file actions
34 lines (32 loc) · 888 Bytes
/
grade_program.py
File metadata and controls
34 lines (32 loc) · 888 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
def student_score():
score = input("Enter student score: ")
#print(score)
try:
# convert score float
score = float(score)
except:
# can't convert letter to a float
score = -1
print("Exception error:", 'please enter score as a number')
return score
grade = ''
if score <= 100 and score >= 90:
grade = 'A'
print(grade)
elif score < 90 and score >= 80:
grade = 'B'
print(grade)
elif score < 80 and score >= 70:
grade = 'C'
print(grade)
elif score < 70 and score >= 60:
grade = 'D'
print(grade)
elif score < 60 and score >=0:
grade = 'F'
print(grade)
else:
print(str(score), "is not in specified score range!")
return -1
return grade
student_score()