-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstudent_result_system.py
More file actions
51 lines (37 loc) · 1.1 KB
/
Copy pathstudent_result_system.py
File metadata and controls
51 lines (37 loc) · 1.1 KB
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
student_list = []
def add_student(id, n, m):
student = {
"id" : id,
"name" : n,
"marks" : m
}
student_list.append(student)
def searchById(id):
for student in student_list:
s_id = student["id"]
if(s_id == id):
return student
def sortByMarks():
return sorted(student_list, key = lambda s:s["marks"], reverse = True)
choice = 1
while(choice):
print("enter any option: \n")
option = input("1.Add student\n2. Search Student\n3.sort students by marks")
if option == '1':
id = int(input("enter Id: "))
n = input("enter name: ")
m = int(input("enter marks: "))
add_student(id, n, m)
elif option == '2':
id = int(input("enter student id"))
result = searchById(id)
if result :
print(result)
else:
print("no such id exist!!")
elif option == '3':
print("\n")
print(sortByMarks())
else:
print("invalid option")
choice = int(input("\ncontinue? --- choose 0 or 1: "))