-
Notifications
You must be signed in to change notification settings - Fork 0
/
uni_class.py
127 lines (75 loc) · 2.69 KB
/
uni_class.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
def main():
class student:
std = []
def __init__(self,name,id,cgpa):
self.name = name
self.id = id
self.cgpa = cgpa
def showId(self):
return self.id
def result(self):
if(self.cgpa > 8.5):
print("Great score")
elif(self.cgpa > 7 and self.cgpa < 8.5):
print("Keep it up")
else:
print("Not gonna pass")
def details(self):
print(f'STUDENT ID: {self.id}\nSTUDENT NAME: {self.name}\nCGPA: {self.cgpa}\nPROGRESS REPORT:',end='')+self.result()
def insert():
if 1:
x = input('Enter the name of the student: ')
y = input('Enter the id of the student: ')
z = input('Enter the cgpa of the student: ')
while not(z.isdigit() and int(z)<10):
z = input('Enter a correct cgpa')
if float(z)<5:
print(f'Hey {x}, You better work on your studies')
data = student(x,y,float(z))
student.std.append(data.__dict__)
print(f'id no {y} has been added')
def search():
found = 0
try:
x= input('Enter your id: ')
for data in student.std:
if x == data['id']:
print('NAME: '+ data['name'])
print('CGPA: '+ str(data['cgpa']))
found=1
# print(data['id'])
if found ==0:
print('Data not found')
except:
print('Ooops!Error')
def decision(x):
try:
return{
'1':insert(),
'2':search(),
'3':delete(),
'4': exit()
}[x]
except:
print('Invalid input')
while True:
y = input('Press 1 if you want to insert data\nPress 2 if you want to search data\nPress 3 if you want to delete a data\npress 4 if you want to exit\n')
if y in ['1','2','3']:
if y is '1':
insert()
print(student.std)
continue
elif y is '2':
search()
continue
else:
search()
continue
else:
x1=input('INVALID OPTION.PRESS * TO CONTINUE OR ELSE TO EXIT :')
if int(ord(x1))==42:
continue
else:
break
if __name__=='__main__':
main()