Cheap VPS host selection
Provide server host evaluation information

Python implementation of student information management system (with detailed code)

Today, I would like to share with you the specific code of implementing the student information management system in python for your reference. The development steps of the student management system are as follows:

1. Display the function menu of student management system

2. Receive function options entered by the user

3. Judge the function options entered by the user and complete relevant operations

The purpose of extracting function code into function is to provide reusability of function code and reduce redundancy of function code.

 #Student list, specially responsible for managing each student's information student_list = [] #Display the function function of the student management system menu def show_menu(): Print ("========================Student Management System V1.0===================") print("1.  Add Students ") print("2.  Delete student ") print("3.  Modify student information ") print("4.  Query student information ") print("5.  Show all student information ") print("6.  Exit ") #Add student function def add_student(): #Realize the function of adding students Name=input ("Please enter your name:") Age=input ("Please enter your age:") Sex=input ("Please enter your gender:") #Each student information is a dictionary type, and the three data items need to be assembled into the dictionary student_dict = {"name": name, "age": age, "sex": sex} #Add student dictionary information to the list student_list.append(student_dict) #Display the function functions of all students def show_all_student(): #Realize the function of displaying all students for index, student_dict in enumerate(student_list): #Student ID=subscript+1 student_no = index + 1 Print ("Student ID:% d Name:% s Age:% s Gender:% s"% (student_no, student_dict["name"], student_dict["age"], student_dict["sex"])) #Delete student function def remove_student(): # 1.  Receive the student ID of the student to be deleted Student_no=int (input ("Please enter the student ID of the student you want to delete:")) # 2.  Generate subscripts according to students index = student_no - 1 #Judge whether the subscript is legal if 0 <= index < len(student_list): # 3.  Delete the specified data from the list according to the subscript student_dict = student_list.pop(index) Print ("% s, deleted successfully!"% student_dict ["name"]) else: Print ("Please enter a legal student number!") #Function to modify student information def modify_student(): # 1.  Receive the student ID to be modified Student_no=int (input ("Please enter the student number you want to modify:")) # 2.  Generate subscripts according to students index = student_no - 1 #Judge whether the subscript is legal if 0 <= index < len(student_list): # 3.  Get the corresponding student dictionary information according to the subscript modify_student_dict = student_list[index] # 4.  Modify student information according to dictionary Modify_student_dict ["name"]=input ("Please enter your modified name:") Modify_student_dict ["age"]=input ("Please enter your modified age:") Modify_student_dict ["sex"]=input ("Please enter your modified gender:") Print ("modified successfully") else: Print ("Please enter your legal student number!") #Query students def query_student(): # 1.  The name of the student to be queried by the receiving user Name=input ("Please enter the name of the student to query:") # 2.  Go through the student list and judge whether the student's name is the designated name for index, student_dict in enumerate(student_list): if student_dict["name"] == name: #Generate students student_no = index + 1 # 3.  If found, output student information and stop the cycle Print ("Student ID:% d Name:% s Age:% s Gender:% s"% (student_no, student_dict["name"], student_dict["age"], student_dict["sex"])) break else: # 4.  The user does not exist after traversing Print ("Sorry, the student information you searched does not exist!") #Development steps of student management system #Tip: Since the system needs to run all the time, the above three steps need to be put into an endless loop, so that the program can be saved to run all the time. #Define the entry function of the program, the first function to be executed by the program def start(): while True: # 1.  Display the function menu of student management system show_menu() # 2.  Receive function options entered by the user Menu_option=input ("Please enter the function options you want to operate:") # 3.  Judge the function options entered by the user and complete relevant operations if menu_option == "1": Print ("Add Students") add_student() elif menu_option == "2": Print ("Delete Student") remove_student() elif menu_option == "3": Print ("Modify student information") modify_student() elif menu_option == "4": Print ("Query student information") query_student() elif menu_option == "5": Print ("Display all student information") show_all_student() elif menu_option == "6": Print break #Start program start()
Do not reprint without permission: Cheap VPS evaluation » Python implementation of student information management system (with detailed code)