1 stu_list = [] 2 def func1(): 3 num_srt = input( ' Please enter the student number: ' ) 4 num = int(num_srt) 5 name = input( ' Please enter the name of the freshman: ' ) 6 age = input( ' Please enter the age of the new student: ' ) 7 stu = { ' stu_num ' :num, ' stu_name ' :name, ' stu_age ' :age} 8 stu_list.append(stu) 9 print (' Added successfully ' ) 10 11 def func2(): 12 num_str = input( ' Please enter student number: ' ) 13 num = int(num_str) 14 is_exists = True 15 for stu in stu_list: 16 num1 = stu.get( ' stu_num ' ) 17 if num1 == num: 18 stu_list.remove(stu) 19 print ( ' Remove successful! ' ) 20 is_exists = False 21 if is_exists: 22 print ( ' The student ID you entered does not exist! ' ) 23 24 def func3(): 25 num_str = input( ' Please enter the student ID of the student you want to modify: ' ) 26 num = int (num_str) 27 is_exists = True 28 for stu in stu_list: 29 num1 = stu.get( ' stu_num ' ) 30 if num1 == num: 31 print( ' Student ID is: ' ,stu.get( ' stu_num ' ), ' Name is: ' ,stu.get( ' stu_name ' ), ' Age is: ' ,stu.get( ' stu_age ' )) 32 new_age = input( ' Please enter the new age: ' ) 33 stu[ ' stu_age ' ]= int(new_age) 34 print ( ' The modification is successful! ') 35 is_exists = False 36 if is_exists: 37 print ( ' The student number you entered does not exist! ' ) 38 39 def func4(): 40 num = int(input( ' Please enter the student number: ' )) 41 is_exists = True 42 for stu in stu_list: 43 num1 = stu.get( ' stu_num ' ) 44 if num1 == num: 45 print ( ' Student number is: ' ,stu.get( ' stu_num ' ),' Name is: ' , stu.get( ' stu_name ' ), ' Age is: ' , stu.get( ' stu_age ' )) 46 is_exists = False 47 if is_exists: 48 print ( ' The student number input is incorrect, please check Then input again! ' ) 49 50 def main(): 51 while True: 52 choice = input( ' A, add student B, delete student C according to student number, modify information D, query E, exit ' ) 53 if choice = = ' A' or choice == 'a': 54 func1() 55 elif choice == 'B' or choice == 'b': 56 func2() 57 elif choice == 'C' or choice == 'c': 58 func3() 59 elif choice == 'D' or choice == 'd': 60 func4() 61 elif choice == ' E ' or choice == ' e ' : 62 break 63 print ( ' Current class student information: ' ) 64 for stu in stu_list: 65 print ( ' Student number is: ' ,stu. get( ' stu_num ' ), ' name is: ' ,stu.get( ' stu_name ' ), ' age is: ' ,stu.get( 'stu_age')) 66 print('****'*10) 67 68 main()