# First: Design a global variable to hold a number of student information, students (student number, name, age), and how the structure of the thinking to be preserved;
# The second question: on the basis of the first question, complete: Let the user enter a new student information (school number, name, age); You save it in a global variable, and provide the user with the ability to see how many students are currently available;
# The third problem: to provide users with the number of students to view the specific information, specify student number to delete the student function
# used to save all the students ' information
Stuinfos = []
# Global Variables
Sno = ""
SName = ""
SAge = ""
# Print Feature Tips
Def printmenu ():
Print ("=" * 42)
Print ("*" * + + "Simple Student information Management system" + "*" * 10)
Print ("=" * 42)
Print ("1. Add student Information")
Print ("2. Delete Student Information")
Print ("3. Query student information for a given school number")
Print ("4. Show all current student Information")
Print ("0. Exit system")
Print ("=" * 42)
# (user input) get a student's information
Def getInfo ():
Global Newsno
Global Newsname
Global Newsage
# These three are global variables, you want to modify them, you must first declare
Newsno = input ("Please enter student's number:")
Newsname = input ("Please enter student's name:")
Newsage = input ("Please enter the student's gender:")
# The data is consolidated into a single unit in the form of a list and then returned
return [Newsno, Newsname, Newsage]
# Add Student Information
Def addstuinfo ():
result = GetInfo ()
Newinfo = {}
newinfo[' sno '] = result[0]
newinfo[' sName '] = result[1]
newinfo[' sAge '] = result[2]
Stuinfos.append (Newinfo)
# # Delete Student Information
# def deletestuinfo ():
# Stuid = input ("Please enter the student number to be queried:")
# print ("=" * 30)
# print ("The student's information is as follows:")
# Print ("Study number name gender")
# for Tempinfo in Stuinfos:
# if Stuid = = tempinfo[' Sno ']:
# Stuinfos.remove (tempinfo[' Sno ')
# stuinfos.remove (tempinfo[' sName ')
# stuinfos.remove (tempinfo[' SAge ')
# Query Student information for a given number
Def selectstuinfo ():
Stuid = input ("Please enter the student number to be queried:")
Print ("=" * 30)
Print ("The student's information is as follows:")
Print ("Study number name gender")
For Tempinfo in Stuinfos:
if Stuid = = tempinfo[' Sno ']:
Print ("%s%s"% (tempinfo[' sno '), tempinfo[' SName '], tempinfo[' SAge '))
Break
# Show all current student information
Def selectallstuinfo ():
Print ("=" * 30)
Print ("The student's information is as follows:")
Print ("Serial Number name gender")
i = 1
For Tempinfo in Stuinfos:
Print ("%d%s%s"% (I, tempinfo[' Sno '], tempinfo[' sName '], tempinfo[' SAge '))
i + = 1
# Main Function Program
def main ():
While True:
# Print prompt information
Printmenu ()
Key = input ("Please enter the action you want to select:")
If key = = ' 1 ':
# Add Student Information
Addstuinfo ()
elif key = = "2":
Pass
elif key = = "3":
# Query Student information for a given number
Selectstuinfo ()
elif key = = ' 4 ':
# Show all current student information
Selectallstuinfo ()
elif key = = ' 0 ':
Exit ()
# Call the main function
Main ()
Development of Python Student Information management system