美文网首页
作业_Day10

作业_Day10

作者: 龙神海王 | 来源:发表于2018-10-14 21:55 被阅读0次

    学生管理系统

    main

    import myfunction
    import time
    
    def backup():
        myfunction.home_page()
        input_number = input('请输入一个1个数字')
        if input_number == '1':
            def  continueadd():
                name = input('请输入姓名')
                english = input('请输入英语成绩')
                pe = input('请输入体育成绩')
                art = input('请输入美术成绩')
                math = input('请输入数学成绩')
                age = input('请输入年龄')
                student_id = next(myfunction.stu_id)
                management_system = {'name': name, 'student_id': student_id, 'english':english , 'pe':pe, 'art':art, 'math':math,
                              'age':age}
                myfunction.management_systems.append(management_system)
                print('添加成功')
                print(myfunction.management_systems)
                print('1.继续添加')
                print('2.返回上一级')
                def back():
                    continue_add = input('请输入一个数字')
                    if continue_add == '1':
                        continueadd()
                    elif continue_add == '2':
                        backup()
                    else:
                        print('输入错误请重新输入')
                        back()
                back()
            continueadd()
        elif input_number == '2':
            print('1.查看所有学生信息')
            print('2.根据名字查看学生信息')
            print('3.返回上一级')
            def back2():
                find_number = input('请输入一个数字')
                if find_number == '1':
                    myfunction.find_all_student()
                    china = input('请输入1返回主页')
                    if china == '1':
                        myfunction.home_page()
                        backup()
                    else:
                        print('输入错误返回主页')
                        backup()
                elif find_number == '2':
                    myfunction.find_student()
                    china = input('请输入1返回主页')
                    if china == '1':
                        myfunction.home_page()
                        backup()
                    else:
                        print('输入错误返回主页')
                        backup()
                elif find_number == '3':
                    backup()
                else:
                    print('输入错误请重新输入')
                    back2()
            back2()
        elif input_number == '3':
            def continue_delet():
                myfunction.delete_student()
                print('删除成功')
                print(myfunction.management_systems)
                print('1.继续删除')
                print('2.返回上一级')
                def back():
                    continue_add = input('请输入一个数字')
                    if continue_add == '1':
                        continue_delet()
                    elif continue_add == '2':
                        backup()
                    else:
                        print('输入错误请重新输入')
                        back()
                back()
            continue_delet()
        elif input_number == '4':
            def continue_find():
                myfunction.check_average_grade()
                print('1.继续查看')
                print('2.返回上一级')
                def back():
                    continue_find3 = input('请输入一个数字')
                    if continue_find3 == '1':
                        continue_find()
                    elif continue_find3 == '2':
                        backup()
                    else:
                        print('输入错误请重新输入')
                        back()
    
                back()
            continue_find()
        elif input_number == '5':
            print('退出系统')
    
    
    
    print('+'*66)
    print((' '*64).center(66,'+'))
    print((' '*64).center(66,'+'))
    print((' '*64).center(66,'+'))
    print((' '*14+'欢迎进入海龙学生管理中心'+' '*26).center(54,'+'))
    print((' '*64).center(66,'+'))
    print((' '*64).center(66,'+'))
    print((' '*64).center(66,'+'))
    print('+'*66)
    def mylogin():
        myaccount = input('请输入账号')
        mypassword = input('请输入密码')
        if myaccount == '1207038216':
            if mypassword == '123456':
                print('正在登录...')
                time.sleep(3)
    
                print('登录成功')
                backup()
    
            else:
                print('密码错误')
                mylogin()
        else:
            print('账号错误')
            mylogin()
    mylogin()
    # if __name__ == '__main__':
    #     backup()
    
    
    
    
    
    
    
    
    

    myfunction

    
    management_systems = [{'name':'dragon','student_id':1,'english':88,'pe':98,'art':78,'math':100,'age':22},\
                         {'name':'sea','student_id':2,'english':98,'pe':96,'art':88,'math':89,'age':23}]
    
    def func3():
        num = 3
        while True:
            yield num
            num += 1
    stu_id = func3()
    
    def find_student():
         name = input('请输入你要查看学生姓名')
         same_num = 0
         for x in range(0, len(management_systems)):
             student = management_systems[x]
             if student['name'] == name:
                 same_num += 1
                 print(same_num,student)
             else:
                 print('没有此学生')
    
    
    def home_page():
        print('+' * 66)
        print((' ' * 64).center(66, '+'))
        print((' ' * 17 + '1.添加学生' + ' ' * 37).center(62, '+'))
        print((' ' * 17 + '2.查找学生' + ' ' * 37).center(62, '+'))
        print((' ' * 17 + '3.删除学生' + ' ' * 37).center(62, '+'))
        print((' ' * 17 + '4.查看某学生平均成绩' + ' ' * 27).center(57, '+'))
        print((' ' * 17 + '5.退出系统' + ' ' * 37).center(62, '+'))
        print((' ' * 64).center(66, '+'))
        print((' ' * 64).center(66, '+'))
        print('+' * 66)
    
    
    def find_all_student():
        for x in range(0, len(management_systems)):
            student = management_systems[x]
            print(student)
    
    
    
    def delete_student():
        delete_name = input('请输入你要删除学生姓名')
        same_student = 0
        for i in range(0,len(management_systems[:])):
            student = management_systems[i]
            if student['name'] == delete_name:
                same_student += 1
        if same_student == 1:
            for j in range(0, len(management_systems[:])):
                student = management_systems[j]
                if student['name'] == delete_name:
                    del management_systems[j]
        else:
            for k in range(0, len(management_systems[:])):
                student = management_systems[k]
                if student['name'] == delete_name:
                    print(management_systems[k])
            print('请选择要删除学生学号')
            same_student_id = input('输入要删除学生学号')
            for x in range(0,len(management_systems[:])):
                student = management_systems[x]
                if same_student_id == student['student_id']:
                    del management_systems[x]
                else:
                    print('本校查无此人')
    
    
    def check_average_grade():
        name1 = input('请输入查看学生姓名')
        for m in range(0, len(management_systems)):
            student = management_systems[m]
            if student['name'] == name1:
                student_averagescores = (student['english'] + student['pe'] + student['art'] + student['math']) / 4
                print(student_averagescores)
    
    

    相关文章

      网友评论

          本文标题:作业_Day10

          本文链接:https://www.haomeiwen.com/subject/qcntzftx.html