慢慢陪我长大 发表于 2021-12-1 19:36:47

大神帮帮我

1.从键盘上录入学生个数
2.依次录入学生学号、语文、数学、英语成绩
3.输入完成后,显示学号成绩及总分
4.设计排序系统:
输入1:按语文降序         输入2:按数学降序         输入3:按英语降序         输入4:按总分降序 输入5:按语文升序         输入6:按数学升序         输入7:按英语升序         输入8:按总分升序
输入其他大于0的数字:提示输入1-8
输入负数:退出查询

xtxzs 发表于 2021-12-9 03:23:51

dictname = {}
one_result = []
two_result = []
three_result =[]
sum_result=[]
count = []
while True:

    print("1.从键盘上录入学生个数")
    print("2.依次录入学生学号、语文、数学、英语成绩")
    print("3.输入完成后,显示学号成绩及总分")
    print("4.设计排序系统")
    print("输入负数:退出查询")

    cmd = eval(input("请输入命令"))

    if cmd == 1:
      number = eval(input("请输入需要录入的学生个数:"))
      for i in range(number):
            data = input("请输入学号,语文,数学,英语成绩,(每项用逗号分开)").split(",")
            count.append(data)
            one = int(data)
            two = int(data)
            three = int(data)
            one_result.append(one)
            two_result.append(two)
            three_result.append(three)
            sum = one+two+three
            sum_result.append(sum)
            dictname] =

      print("{}   {}   {}   {}   {}".format("学号","语文","数学","英语","总分"))
      for j in count:
            print("{}   {}      {}      {}      {}".format(j,dictname,dictname,dictname,dictname))
      print(dictname)


    elif cmd == 4:
      print("输入1:按语文降序\n"
            "输入2:按数学降序\n"
            "输入3:按英语降序\n"
            "输入4:按总分降序\n"
            "输入5:按语文升序\n"
            "输入6:按数学升序\n"
            "输入7:按英语升序\n"
            "输入8:按总分升序")
      number = eval(input("请输入命令"))
      if number > 8 :
            print("命令输入错误")
            continue
      elif number<0:
            break
      else:

            if number == 1:
                  new_result = one_result
                  new_result.sort(reverse=True)
                  print("{}   {}   {}   {}   {}".format("学号","语文","数学","英语","总分"))
                  for i in new_result:
                        for j in count:
                            if i==dictname:
                              print("{}   {}      {}      {}      {}".format(j,dictname,dictname,dictname,dictname))
            elif number == 2:
                new_result = two_result
                new_result.sort(reverse=True)
                print("{}   {}   {}   {}   {}".format("学号","语文","数学","英语","总分"))
                for i in new_result:
                  for j in count:
                        if i==dictname:
                            print("{}   {}      {}      {}      {}".format(j,dictname,dictname,dictname,dictname))

            elif number == 3:
                new_result = three_result
                new_result.sort(reverse=True)
                print("{}   {}   {}   {}   {}".format("学号", "语文", "数学", "英语", "总分"))
                for i in new_result:
                  for j in count:
                        if i==dictname:
                            print("{}   {}      {}      {}      {}".format(j,dictname,dictname,dictname,dictname))

            elif number == 4:

                new_result = sum_result
                new_result.sort(reverse=True)
                print("{}   {}   {}   {}   {}".format("学号", "语文", "数学", "英语", "总分"))
                for i in new_result:
                  for j in count:
                        if i==dictname:
                            print("{}   {}      {}      {}      {}".format(j,dictname,dictname,dictname,dictname))

            elif number == 5:
                new_result = one_result
                new_result.sort()
                print("{}   {}   {}   {}   {}".format("学号","语文","数学","英语","总分"))
                for i in one_result:
                  for j in count:
                        if i==dictname:
                            print("{}   {}      {}      {}      {}".format(j,dictname,dictname,dictname,dictname))

            elif number == 6:
                new_result = two_result
                new_result.sort()
                print("{}   {}   {}   {}   {}".format("学号","语文","数学","英语","总分"))
                for i in two_result:
                  for j in count:
                        if i==dictname:
                            print("{}   {}      {}      {}      {}".format(j,dictname,dictname,dictname,dictname))
            elif number == 7:
                new_result = three_result
                new_result.sort()
                print("{}   {}   {}   {}   {}".format("学号","语文","数学","英语","总分"))
                for i in three_result:
                  for j in count:
                        if i==dictname:
                            print("{}   {}      {}      {}      {}".format(j,dictname,dictname,dictname,dictname))

            elif number == 8:
                new_result = sum_result
                new_result.sort()
                print("{}   {}   {}   {}   {}".format("学号", "语文", "数学", "英语", "总分"))
                for i in sum_result:
                  for j in count:
                        if i==dictname:
                            print("{}   {}      {}      {}      {}".format(j,dictname,dictname,dictname,dictname))
    if cmd<0:
      break

xtxzs 发表于 2021-12-9 03:24:33

简陋版,没做异常处理,没做函数封装,没做数据库保存的简陋版本,将就看下呗
页: [1]
查看完整版本: 大神帮帮我