-
Notifications
You must be signed in to change notification settings - Fork 0
/
grade.py
40 lines (34 loc) · 817 Bytes
/
grade.py
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
35
36
37
38
39
## Using the 'and' statement
score = int(input("Score: "))
# if score >= 90 and score <= 100:
# print("Grade: A")
# elif score >= 80 and score < 90:
# print("Grade: B")
# elif score >= 70 and score < 80:
# print("Grade: C")
# elif score >= 60 and score < 70:
# print("Grade: D")
# else:
# print("Grade: F")
# ## Better approach for the above:
# if 90 <= score <= 100:
# print("Grade: A")
# elif 80 <= score < 90:
# print("Grade: B")
# elif 70 <= score < 80:
# print("Grade: C")
# elif 60 <= score < 70:
# print("Grade: D")
# else:
# print("Grade: F")
## Even simpler approach:
if score >= 90:
print("Grade: A")
elif score >= 80:
print("Grade: B")
elif score >= 70:
print("Grade: C")
elif score >= 60:
print("Grade: D")
else:
print("Grade: F")