weixin_53692139 2021-12-21 18:23 采纳率: 0%
浏览 50

用Python的数据结构编写一个简单的学生成绩管理系统

可输入学生学号,以及五门课程的成绩
且可增删,浏览,打印

  • 写回答

1条回答 默认 最新

  • 关注

    参考下

    # -*- coding :  utf-8 -*-
    # @Time      :  2020/8/8
    # @author    :  王小王
    # @Software  :  PyCharm
    # @CSDN      :  https://blog.csdn.net/weixin_47723732
    
    scores = []
    choice = None
    print('''
            成绩录入小程序
            0 - 结束程序
            1 - 输入姓名成绩并录入
            2 - 打印排名好后的成绩
            3 - 查找特定学生的成绩
            4 - 删除特定学生的成绩
         ''')
    while choice != "0":
        choice = input("Choice: ")
        if choice == "0":
            print("结束程序!")
        elif choice == "1":
            name = input("输入姓名: ")
            score = int(input("输入成绩: "))
            listing = (score, name)
            scores.append(listing)
            scores.sort(reverse=True)
        elif choice == "2":
            print("  成绩排名")
            print("姓名\t成绩")
            for listing in scores:
                score, name = listing
                print(name, "\t", score)
        elif choice == "3":
            Name = input("输入你要查找的姓名:")
            for each in scores:
                if each[1] == Name:
                    score ,name=each
                    print("姓名\t成绩")
                    print(name, "\t", score  )
        elif choice == "4":
            Name = input("输入您要删除成绩的姓名: ")
            for each in scores:
                if each[1] == Name:
                    scores.remove(each)
        else:
            print("你输入的选择有误,请检查!")
    input("\n\nPress the enter key to exit.")
    
    

    如有帮助,请点击我的回答下方的【采纳该答案】按钮帮忙采纳下,谢谢!

    img

    评论 编辑记录

报告相同问题?

问题事件

  • 创建了问题 12月21日