基于教材发放系统的学生活动模拟与实现
2025-04-20 13:36

好的,下面是一个简单的示例代码:
class Student:
def __init__(self, student_id):
self.student_id = student_id
self.textbooks = []
def add_textbook(self, textbook_name):
self.textbooks.append(textbook_name)
def remove_textbook(self, textbook_name):
if textbook_name in self.textbooks:
self.textbooks.remove(textbook_name)
# 创建学生对象并添加教材
students = {}
for i in range(1, 6): # 模拟五个学生
students[i] = Student(i)
students[i].add_textbook(f"Textbook {i}")
# 打印所有学生的教材情况
for student in students.values():
print(f"Student {student.student_id} has textbooks: {', '.join(student.textbooks)}")
本站知识库部分内容及素材来源于互联网,如有侵权,联系必删!
标签:教材发放系统

