赞
踩
- #!/usr/bin/env python
- # -*- coding:utf-8 -*-
- # @Author : {玄铁重剑无锋}
- # @License : (C) Copyright 2021 玄铁重剑无锋, All rights reserved.
- # @Contact : {sfrexpect@163.com}
- # @File : 03_班级按成绩分组小程序.py
- # @Time : 2021/8/29 21:53
- # @Desc :
- stu_list = [['李渊', 82], ['李世⺠', 7], ['侯君集', 5], ['李靖', 58], ['魏征',41], ['房⽞龄', 64], ['杜如晦', 65], ['柴绍', 94], ['程知节', 45], ['尉迟恭', 94],['秦琼', 54], ['⻓孙⽆忌', 85], ['李存恭', 98], ['封德彝', 16], ['段志⽞', 44], ['刘弘基', 18], ['徐世绩', 86], ['李治', 19], ['武则天', 39], ['太平公主', 57], ['⻙后',76], ['李隆基', 95], ['杨⽟环', 33], ['王勃', 49], ['陈⼦昂', 91], ['卢照邻', 70],['杨炯', 81], ['王之涣', 82], ['安禄⼭', 18], ['史思明', 9], ['张巡', 15], ['雷万春', 72], ['李⽩', 61], ['⾼⼒⼠', 58], ['杜甫', 27], ['⽩居易', 5], ['王维', 14],['孟浩然', 32], ['杜牧', 95], ['李商隐', 34], ['郭⼦仪', 53], ['张易之', 39], ['张昌宗', 61], ['来俊⾂', 8], ['杨国忠', 84], ['李林甫', 95], ['⾼适', 100], ['王昌龄',40], ['孙思邈', 46], ['⽞奘', 84], ['鉴真', 90], ['⾼骈', 85], ['狄仁杰', 62], ['⻩ 巢', 79], ['王仙芝', 16], ['⽂成公主', 13], ['松赞⼲布', 47], ['薛涛', 79], ['⻥⽞机', 16], ['贺知章', 20], ['李泌', 17], ['韩愈', 100], ['柳宗元', 88], ['上官婉⼉ 五代⼗国:朱温', 55], ['刘仁恭', 6], ['丁会', 26], ['李克⽤', 39], ['李存勖', 11],['葛从周', 25], ['王建', 13], ['刘知远', 95], ['⽯敬瑭', 63], ['郭威', 28], ['柴 荣', 50], ['孟昶', 17], ['荆浩', 84], ['刘彟', 18], ['张及之', 45], ['杜宇', 73],['⾼季兴', 39], ['喻皓', 50], ['历真', 70], ['李茂贞', 6], ['朱友珪', 7], ['朱友贞',11], ['刘守光', 2]]
- # 学生分组后的列表,新列表
- new_stu_list = [[], [], [], [], []]
- # 成绩的5个等级
- grade_list = [90, 80, 70, 60, 0]
- # 测试成绩等级的输出类型为 int
- # print(type(grade_list[0]))
- # 实现成绩5个等级的控制
- for i in range(5):
- # 该等级对所有学生都筛选一遍
- for s in range(len(stu_list)):
- # print(s)
- # print(stu_list[s][1])
- # print(grade_list[i])
- # print("-------------")
- if stu_list[s][1] >= grade_list[i]:
- # linshi_list.append(stu_list[s])
- new_stu_list[i].append(stu_list[s])
- # 如果成绩不符合等级要求,要继续循环,筛选出剩下合格的元素
- else:
- continue
- # 每一个等级的内容筛选出来要删掉,避免影响下个等级的筛选
- for d in new_stu_list[i]:
- # print(d, "-----------")
- stu_list.remove(d)
- print(new_stu_list[0])
- print(new_stu_list[1])
- print(new_stu_list[2])
- print(new_stu_list[3])
- print(new_stu_list[4])
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。