day6 作业

2018-07-24  本文已影响0人  FansYuercero
student = []
flag =True
while flag:
    print('欢迎进入前锋学生管理系统!')
    print('1.添加学生')
    print('2.根据姓名查看学生信息')
    print('3.根据姓名删除学生')
    print('4.查看班级所有学生信息')
    print('5.求指定学生的平均成绩')
    print('q.退出系统')
    choose = input('选择操作:')
    while choose=='1':
        print('请选择你要添加几个学生:')
        index1 = int(input('--->:'))
        for x in range(0,index1):
            data = {}
            student.append(data)
            student[x]['姓名'] = input('请输入学生姓名:')
            student[x]['学号'] = input('请输入学生学号:')
            student[x]['英语'] = input('请输入学生英语:')
            student[x]['体育'] = input('请输入学生体育:')
            student[x]['美术'] = input('请输入学生美术:')
            student[x]['数学'] = input('请输入学生数学:')
            student[x]['年龄'] = input('请输入学生年龄:')
        print('1.继续添加')
        print('2.返回上级')
        choose1 = int(input('>>>>>'))
        if choose1!=1 or choose1==2:
            choose=False
        else:
            continue
    while choose=='2':
        name = input('请输入你要查看的学生姓名:')
        for x in range(0, len(student)):
            if name==student[x]['姓名']:
                print(student[x])
        print('1.继续查看')
        print('2.返回上级')
        choose2 = int(input('-->'))
        if choose2 != 1 or choose == 2:
            choose=False
        else:
            continue
    while choose=='3':
        name = input('请输入你要删除的学生姓名:')
        for x in student[:]:
            if name==x['姓名']:
                student.remove(x)

        print(student)

        print('1.继续删除')
        print('2.返回上级')
        choose3 = int(input('--->'))
        if choose3 != 1 or choose3 == 2:
            choose=False
        else:
            continue

    while choose=='4':
        for x in student:
            print(x)
        print('1.返回上级')
        choose4 = int(input('-->'))
        if choose4 == 1:
            choose=False
        continue
    while choose=='5':
        name = input('请输入你想要查看的学生的平均成绩:')
        sum1 = 0
        for x in range(0, len(student)):
            if name == student[x]['姓名']:
                english = int(student[x]['英语'])
                math = int(student[x]['数学'])
                art = int(student[x]['美术'])
                pe = int(student[x]['体育'])
                sum1=(english+math+art+pe)/4

                print('该生的平均成绩为%.2f' % sum1)
        print('1.继续查询')
        print('2.返回上级')
        choose5 = int(input('--->'))
        if choose5 != 1 or choose5 == 2:
            choose=False
        else:
            continue
    while choose=='q':

        flag=False
        break






上一篇 下一篇

猜你喜欢

热点阅读