创建一个教师实例姓名为Zheng Li编号为1001性别为Female1978年1月1日生身份证号为1234567890职务为professor部门为CST。创建一个助教实例姓名为Li Chao编号为011401性别为Male1988年6月1日生身份证号为12345619880601职务为TA部门为CST班号为cst61专业为computer science导师为Zheng Li。依次输出该助教的
写代码如下:
class Teacher: def init(self, name, id, gender, birthday, id_card, position, department): self.name = name self.id = id self.gender = gender self.birthday = birthday self.id_card = id_card self.position = position self.department = department
class Assistant: def init(self, name, id, gender, birthday, id_card, position, department, class_num, major, mentor): self.name = name self.id = id self.gender = gender self.birthday = birthday self.id_card = id_card self.position = position self.department = department self.class_num = class_num self.major = major self.mentor = mentor
teacher = Teacher("Zheng Li", 1001, "Female", "1978-01-01", "1234567890", "professor", "CST") assistant = Assistant("Li Chao", "011401", "Male", "1988-06-01", "12345619880601", "TA", "CST", "cst61", "computer science", teacher.name)
print("助教姓名:", assistant.name) print("助教编号:", assistant.id) print("助教部门:", assistant.department) print("助教班号:", assistant.class_num) print("助教专业:", assistant.major) print("助教导师:", assistant.mentor
原文地址: https://www.cveoy.top/t/topic/hllf 著作权归作者所有。请勿转载和采集!