-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext_part.py
More file actions
201 lines (185 loc) · 6.81 KB
/
next_part.py
File metadata and controls
201 lines (185 loc) · 6.81 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
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# all functions here
import os
all_data = [
{
'f_name': 'Mubashir',
'l_name': 'Haider',
'class': 'BSCS', 'dofbirth':
'28/10/2003',
'roll': '23',
'fee': '25000'
},
{
'f_name': 'Ali Raza',
'l_name': 'Yameen',
'class': 'BBA',
'dofbirth':
'5/10/2000',
'roll': '25',
'fee': '35000'
},
{
'f_name': 'Usman',
'l_name': 'Malik',
'class': 'BSCS',
'dofbirth': '26/10/2002',
'roll': '27',
'fee': '12000'
}
]
def main_menu():
os.system('clear')
print("*********** OXFORD UNIVERSITY *************")
print("*"*20)
print("1: View All Students")
print("2: Add New Student")
print("3: Edit a student")
print("4: Expell a student")
print("5: Search a student")
print("0: Exit")
def choice():
choice = int(input("Enter your Choice: "))
if choice == 1:
view_all_students()
elif choice == 2:
add_new_student()
elif choice == 3:
edit_student()
elif choice == 4:
expell_student()
elif choice == 5:
search_student()
elif choice == 0:
exit()
else:
print("Invalid Choice")
def view_all_students():
os.system('clear')
for elements in all_data:
print(
f"{elements['roll']} - {elements['f_name']} - {elements['l_name']} - {elements['class']} - {elements['fee']}")
print()
input("Press any key to go Back")
def add_new_student():
os.system('clear')
first_name = input("Enter your First Name: ")
last_name = input("Enter your Last name: ")
class_ = input("Enter you Class: ")
dob_ = input("Enter your Date of Birth: ")
roll_ = input("Enter Your Roll Number: ")
fees_ = input("Enter your Fee: ")
student = {
'f_name': first_name,
'l_name': last_name,
'class': class_,
'dofbirth': dob_,
'roll': roll_,
'fee': fees_
}
all_data.append(student)
os.system('clear')
print(f"The Student {student['f_name']} is added Successfully ")
input("Press any key to go Back")
def edit_student():
os.system('clear')
given_roll = input("Enter Roll Number: ")
for student in all_data:
if student['roll'] == given_roll:
while True:
os.system('clear')
print(
"********************** Here is your Data *****************************")
print()
print(
f" Name: {student['f_name']} {student['l_name']} -- Class: {student['class']} --DOB: {student['dofbirth']} -- Roll No: {student['roll']} -- Fees: {student['fee']}")
print()
print("Which Element You want to Change:")
print()
print("1: First Name")
print("2: Last Name")
print("3: Class")
print("4: DOB")
print("5: Roll No")
print("6: Fee")
print("0: Exit")
choice_ = int(input("Enter Your Choice: "))
if choice_ == 1:
os.system('clear')
new_f_name = input("Enter Your New First Name: ")
student['f_name'] = new_f_name
print(" YOUR FIRST NAME HAS BEEN CHANGED SUCCESSFULLY")
input("Press any Key to Go Back")
elif choice_ == 2:
os.system('clear')
new_l_name = input("Enter Your New Last Name: ")
student['l_name'] = new_l_name
print(" YOUR LAST NAME HAS BEEN CHANGED SUCCESSFULLY")
input("Press any Key to Go Back")
elif choice_ == 3:
os.system('clear')
new_class_name = input("Enter Your New Class Name: ")
student['class'] = new_class_name
print(" YOUR CLASS HAS BEEN CHANGED SUCCESSFULLY")
input("Press any Key to Go Back")
elif choice_ == 4:
os.system('clear')
new_dob = int(input("Enter Your New Date of Birth: "))
student['dofbirth'] = new_dob
print(" YOUR DATE OF BIRTH HAS BEEN CHANGED SUCCESSFULLY")
input("Press any Key to Go Back")
elif choice_ == 5:
os.system('clear')
new_roll = int(input("Enter Your New Roll Number: "))
student['roll'] = new_roll
print(" YOUR ROLL NUMBER HAS BEEN CHANGED SUCCESSFULLY")
input("Press any Key to Go Back")
elif choice_ == 6:
os.system('clear')
new_fee = int(input("Enter Your New Fee: "))
student['fee'] = new_fee
print(" YOUR FEE HAS BEEN CHANGED SUCCESSFULLY")
input("Press any Key to Go Back")
elif choice_ == 0:
os.system('clear')
break
else:
os.system('clear')
print("Invalid Choice")
def expell_student():
os.system('clear')
for_expel = (input("Enter Roll Number: "))
for student in all_data:
if student['roll'] == for_expel:
os.system('clear')
print(" Here is your Data ")
print()
print(f" Name: {student['f_name']} {student['l_name']} -- Class: {student['class']} --DOB: {student['dofbirth']} -- Roll No: {student['roll']} -- Fees: {student['fee']}")
print()
student_want = input(" Do you Want to Expell that Student (Y/N): ")
if student_want == 'y':
os.system('clear')
all_data.remove(student)
print(f"Roll Number : {for_expel} has been Expelled")
input("Press any Key to Go Back")
elif student_want == 'n':
os.system('clear')
print("Ok")
input("Press any Key to Go Back")
break
else:
os.system('clear')
print("Invalid Choice")
input("Press any Key to Go Back")
def search_student():
os.system('clear')
search = input("1: Search by Roll Number: ")
x = 0
for student in all_data:
if student['roll'] == search:
os.system('clear')
print(
"********************** Here is your Data *****************************")
print()
print(f" Name: {student['f_name']} {student['l_name']} -- Class: {student['class']} --DOB: {student['dofbirth']} -- Roll No: {student['roll']} -- Fees: {student['fee']}")
input("Press any Key to Go Back")
x += 1