python-3.x - 记住上次展示作业的3个学生
问题描述
上次展示作业的3名学生。每次运行此程序时,它应该选择一组新的 3 名学生。
解决方案
假设给定学生的卷号
students_roll_number = [1,2,3,4,5,6,7,8,9,10,11]
students_homework_showed = [3,4,5]
让尚未展示作业的学生
students_homework_pending = [students_roll_number[i] for i in range(len(students_roll_number)) if students_roll_number[i] not in students_homework_showed]
输出是
students_homework_pending = [1, 2, 6, 7, 8, 9, 10, 11]
现在我们从待定列表中挑选 3 名学生
students_to_check = []
for i in range(3):
students_homework_showed.append(students_homework_pending[i])
students_to_check.append(students_homework_pending[i])
新学生可供选择
print("chosen student is : ", students_to_check)
推荐阅读
- xquery - XQuery (BaseX) 中全文搜索的不同方式的速度
- blazor - 代码中的 Blazor NavigationManager NullReference 错误
- c# - 如何运行多个 WinForms 应用程序实例
- python - numpy 中的图像混合返回纯白色图像
- unit-testing - Quarkus kubernetesMockServer 用于应用程序初始化
- java - 让我的 Spring 测试切片扫描单个类而不是整个包
- inheritance - 与继承相关的 F# 编译错误
- typescript - 如何打破 Firestore 上的 querySnapshot?
- javascript - 如何使用 jQuery 在不同列表上分离和重新附加具有不同类的项目?
- ios - 如何在没有 Google 帐户的情况下使用 Firebase App 分发?