-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrade.py
More file actions
46 lines (42 loc) · 1010 Bytes
/
Copy pathgrade.py
File metadata and controls
46 lines (42 loc) · 1010 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
35
36
37
38
39
40
41
42
43
44
45
46
# Program to finds out the grade using a switch case.
marks = float(input("Enter your marks:"))
grades = {
range(0, 60): "F",
range(60, 65): "D",
range(65, 70): "D+",
range(70, 74): "C-",
range(74, 77): "C",
range(77, 80): "C+",
range(80, 84): "B-",
range(84, 87): "B",
range(87, 90): "B+",
range(90, 101): "A+",
}
for key in grades.keys():
if marks in key:
grade = grades[key]
else:
grade = "Error"
match grade:
case "A+":
print("You have got A+")
case "B+":
print("You have got B+")
case "B":
print("You have got B")
case "B-":
print("You have got B-")
case "C+":
print("You have got C+")
case "C":
print("You have got C")
case "C-":
print("You have got C-")
case "D+":
print("You have got D+")
case "D":
print("You have got D")
case "F":
print("You have got F")
case "Error":
print("Invalid Marks.")