程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python student information management system (simplified version)

編輯:Python

Code :

# Storing student information student = list()# Display a menu def showMenu(): print("1. Add student information ") print("2. Delete student information ") print("3. Modify student information ") print("4. Show student information ") print("0. Exit the system ") select = eval(input(" operation :")) return select# Add student information def addStudent(): print("----- Add student information -----") name = input(" full name :") sex = input(" Gender :") age = input(" Age :") phone = input(" Telephone :") student.append({"name":name,"sex":sex,"age":age,"phone":phone}) print(" Add success !")# Show student information def showStudent(): if len(student) == 0: print(" The current student information is empty !") else: print("----------- Student information ------------") print(" Serial number \t full name \t Gender \t Age \t Telephone ") for i in range(0,len(student)): print("%d\t%s\t%s\t%s\t%s"%(i+1,student[i].get('name'),student[i].get('sex'),student[i].get('age'),student[i].get('phone'))) print("------------------------------")# Delete student information def delStudent(): print("--- Deleting operation in progress ---") print("----- Current student information ------") showStudent() select = eval(input(" Please input the student serial number to delete :")) del student[select-1] print(" Delete successful !")# Modify student information def reviseStudent(): studict = {1: "name", 2: "sex", 3: "age", 4: "phone"} print("----- Modification in progress -----") showStudent() num = eval(input(" Please input the student serial number to be modified :")) print("1- Change the name \n2- Change gender \n3- Change the age \n4- Change the phone number ") revisenum = eval(input(" Please input the serial number of the information to be modified :")) newstr = input(" Please enter new information :") student[num-1][studict[revisenum]] = newstr print(" Modification successful !")# Main running function def init(): while True: # Show student information  showStudent() # Show menu  select = showMenu() if select == 1: addStudent() elif select == 2: delStudent() elif select == 3: reviseStudent() elif select == 4: showStudent() elif select == 0: # Exit the system  break else: print(" Incorrect input ! Please do it again !") continue

Running results :

1. Add student information

2. Delete student information

3. Modify student information

4. Show student information

( More source code 、 Information 、 Courseware 、 Error reporting solutions can be obtained by scanning below )


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved