Function application: student management system

Time:2020-8-28

1、 System function

  • Add students
  • Delete student
  • Modify student information
  • Query student information
  • Display college information
  • Exit the system

2、 Step analysis

1. Display function interface

2. User input function serial number

3. Perform different function functions according to the input serial number

while True:
    #1. Display the function interface
    info_print()
    #2. User input function serial number
    I = int (input ('Please select function '))
    #3. Execute different function functions according to the input serial number
    if i==1:
        Print ('add students')
        add_info()
    elif i==2:
        Print ('delete student ')
        delete_info()
    elif i == 3:
        Print ('modify student information ')
        modif_info()
    elif i == 4:
        Print ('search students')
        search_info()
    elif i==5:
        Print ('print all students')
        display_all()
    elif i==6:
        Flag = input ('are you sure you want to exit? y/n')
        if flag=='y':
            Print ('exit succeeded ')
            break
    else:
        Print ('Please input the digital instruction within 1-6 ')

3、 Function realization

1. The main interface displays info_ print()

#Display function interface
def info_print():
    Print ('Please select the following functions: --- --- ')
    Print ('1: add students')
    Print ('2: delete student ')
    Print ('3: modify student information ')
    Print ('4: query student information ')
    Print ('5: display all student information ')
    Print ('6: exit system ')
    print('-'*20)

2. Add student_ info() 

#Define global variables
info =[]
def add_info():
    "Add student"
    #Input
    Sid = input ('Please enter student number: ')
    Name = input ('Please input student name: ')
    Tel = input ('Please input student telephone number: ')
    #Create student dictionary
    student={'sid': sid, 'name':name, 'tel':tel}
    #Check whether the name of the student exists. If it exists, an error will be reported
    global info
    for i in info:
        if student['name']==i['name']:
            Print ('the student already exists')
            return
    #Save student information
    info.append(student)
    Print ('added successfully ')

 

3. Delete student_ info()

def delete_info():
    "Delete student"
    #Input
    del_ Name = input ('Please input the name of the deleted student: ')

    #Judge whether the students exist, delete and no error report
    global info
    for i in info:
        if del_name == i['name']:
            info.remove(i)
            Print ('deleted successfully ')
            break
    else:
        Print ('the user does not exist ')

4. Modify student information_ info()

def modif_info():
    "Modify student information"
    #Find
    modif_ Name = input ('Please input the name of the student to be modified: ')

    #Check whether the name of the student exists. If it exists, an error will be reported
    global info
    for i in info:
        if modif_name == i['name']:
            Tel = input ('New phone number: ')
            i['tel']=tel
            Print ('modified successfully ')
            break
    else:
        Print ('the user does not exist ')

5. Search student search_ info()

def search_info():
    'search students'
    search_ Name = input ('Please input the name of the student to be searched: ')

    #Judge whether there is an output and there is no error report
    global info
    for i in info:
        if search_name==i['name']:
            print(i)
            break
    else:
        Print ('the user does not exist ')

6. Print all students

def display_all():
    "Print all students"
    global info
    for i in info:
        print(i)

 

 

Recommended Today

Java security framework

The article is mainly divided into three parts1. The architecture and core components of spring security are as follows: (1) authentication; (2) authority interception; (3) database management; (4) authority caching; (5) custom decision making; and;2. To build and use the environment, the current popular spring boot is used to build the environment, and the actual […]