Use python to complete a super basic student management system for your reference, the specific content is as follows
**Description: **
1、 This student management system is very, very simple, with only add, display, check, delete, and modify functions, which is easy to understand for Python novices.
2、 The storage of information only uses dictionaries and lists.
3、 Do not spray if you don't like it.
**Code: **
1、 Main loop frame
while True:print(info_str)
action =input("Please enter what you want to do:")if action =='0':print("Goodbye.")break
elif action =='1':print("New student information")
elif action =='2':print("Show all students")
elif action =='3':print("Query student information")
elif action =='4':print("Delete student information")
elif action =='5':print("Modify student information")else:print("There is an error in your input, please re-enter.")
2、 Source code
info_str ="""
*************************1. New student information
2. Show all students
3. Query student information
4. Delete student information
5. Modify student information
0. Exit system
*************************"""
""" Name, language score, math score, English score, total score"""
students =[{'Name':'Zhang Dapao','Chinese':'95','Math':'65','English':'65','Score':'215'},{'Name':'Zhang Yida','Chinese':'65','Math':'95','English':'65','Score':'215'},{'Name':'Snack','Chinese':'65','Math':'65','English':'95','Score':'215'},]while True:""""Main loop"""
print(info_str)
action =input("Please enter what you want to do:")if action =='0':"""End condition"""print("Sayonara.")break
elif action =='1':print("New student information")
Name =input("Please enter the name:")
Chinese =input("Please enter the language score:")
Math =input("Please enter math grades:")
English =input("Please enter English score:")
Score =int(Chinese)+int(Math)+int(English)
student={'Name':Name,'Chinese':Chinese,'Math':Math,'English':English,'Score':Score
}
students.append(student)
elif action =='2':print("Show all students")for student in students:print(student)
elif action =='3':print("Query student information")
Name =input('Please enter the name to be queried:')for student in students:if student['Name']== Name:print(student)else:print("{}Information does not exist".format(Name))
elif action =='4':print("Delete student information")
Name =input("Please enter the name to be deleted:")for student in students:if student['Name']== Name:
students.remove(student)breakelse:print("{}Information does not exist".format(Name))
elif action =='5':print("Modify student information")
Name =input("Please enter the name to be modified:")for student in students:if student['Name']== Name:
student['Name']=input("Please enter the name:")
student['Chinese']=input("Please enter the language score:")
student['Math']=input("Please enter math grades:")
student['English']=input("Please enter English score:")
student['Score']=int(student['Chinese'])+int(student['Math'])+int(student['English'])else:print("{}Information does not exist".format(Name))else:print("There is an error in your input, please re-enter.")
to sum up
1、 The code framework is concise and clear, and adding functions only needs to be added in the main loop.
2、 Super basic, don't spray if you don't like it.
Recommended Posts