-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHw2.py
90 lines (73 loc) · 1.99 KB
/
Hw2.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
# add one student
def addStudents():
nm1 = input("Enter Name ")
srnm1 = input("Enter Surname")
list.append(nm1 + srnm1)
print(nm1 + srnm1, "Successfully added!!")
# add one student
def deleteStudents():
nm1 = input(" Enter Name ")
srnm1 = input(" Enter Surname")
list.remove(nm1+srnm1)
print(nm1 + srnm1 ,"deleted ")
# add multiple students
def multipleAddStudents():
num=int(input("How Many Student Will You Add?"))
count=0
while count<num:
nm1 = input(" Enter Name ")
srnm1 = input(" Enter Surname")
list.append(nm1+srnm1)
print(nm1 + srnm1 ,"added ")
count+=1
# delete multiple students
def multipleDeleteStudents():
num=int(input(" How Many Student Will You Add"))
count=0
while count<num:
nm1 = input(" Enter Name")
srnm1 = input("Enter Surname ")
list.remove(nm1+srnm1)
print(nm1 + srnm1 ,"deleted ")
count+=1
# find student number [index number in the list is student number ]
def findStudentNumber():
nm1 = input(" Enter Name")
srnm1 = input("Enter Surname")
if nm1 + srnm1 in list:
num = list.index(nm1 + srnm1)
print(str(nm1 + srnm1) , "student's number is: " , str(num))
else:
print("Try again !")
#viewing student
def printStudent():
for i in list:
print(i)
list=[] # holds student list
#main step
print("""
1. Add Student
2. Delete Student
3. Add Multiple Student
4. Delete Multiple Student
5. Find Student Number
6. Print Student list
7. Exit
""")
while True:
islem = int(input("Please Select Steps: "))
if islem == 1:
addStudents()
elif islem == 2:
deleteStudents()
elif islem == 3:
multipleAddStudents()
elif islem == 4:
multipleDeleteStudents()
elif islem == 5:
findStudentNumber()
elif islem == 6 :
printStudent()
elif islem == 7 :
print("Exit Successful...")
break