-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathProject-22(Menu driven).py
87 lines (78 loc) · 2.1 KB
/
Project-22(Menu driven).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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import os
def help(x):
c= x.split(":")
return int(c[-1])
list1=[]
stu_no=int(input("No. of Students: "))
for i in range(stu_no):
n=input("Name: ")
m=input("Marks: ")
print()
c=n+":"+m
list1.append(c)
list1.sort(key=help,reverse=True)
print(list1)
print()
print()
############################ LOOP STARTS HERE ########################
while True:
c=0
print("Menu :")
print()
print('''1.) Display the Student's Marks with Rank ''')
print('''2.) Update and display the student Rank''')
print('''3.) Display the specific student's Rank''')
print('''4.) Clear the screen''')
print('''5.) Exit''')
print()
a=input("Enter your choice: ")
print()
if a=="1":
print()
for i in list1:
c=c+1
print("Rank =",c)
zz= i.split(":")
print(" Name:",zz[0])
print(" Marks:",zz[-1])
print()
####################### UPDATION IN MARKS ########################
elif a=="2":
n=input("Name: ")
m=input("Marks: ")
print()
ap=n+":"+m
print("The updated list :")
for j in list1:
if n in j:
del list1[c]
list1.append(ap)
list1.sort(key=help,reverse=True)
break
c=c+1
print()
print()
rank=1
for x in list1:
print("Rank:",rank)
zz=x.split(":")
print(" Name:",zz[0])
print(" Marks:",zz[-1])
print()
rank=rank+1
elif a=="3":
nm_rank=1
n=input("Enter Name: ")
print()
for i in list1:
if n in i:
zz=i.split(":")
print("Name:",zz[0])
print(" Marks:",zz[-1])
print(" Rank:",nm_rank)
nm_rank=nm_rank+1
print()
elif a=="4":
os.system('cls')
elif a=="5":
break