# # 1、学校数据与功能整合class school: def __init__(self, school_name, school_adress): self.name = school_name self.adrss = school_adress def info(self): print(f'校名{self.name},地址{self.adrss}')school.obj = school('oldboy', '上海青浦')school.info(school.obj)# # 2、课程数据与功能进行整合class course: def __init__(self, name, period, price): self.name = name self.period = period self.price = price def info(self): print(f'课程{self.name},课程周期{self.period},课程价格{self.price}')course_obj = course('课程A', '14天', '20块')course_obj.info()# # 3、学生数据与功能进行整合class classmates: def __init__(self, name, age, id, school, gender): self.name = name self.age = age self.id = id self.school = school self.gender = gender def info(self): print(f'姓名:{self.name}年龄:{self.age}学号:{self.id}学校:{self.school}性别:{self.gender}')wangmou = classmates('王某','18','151617','上海小天才幼儿园','男')wangmou.info()# # 4、讲师数据与功能进行整合class teacher: def __init__(self,name,age,salary,level): self.name = name self.age = age self.salary = salary self.level = level def info(self): print(f'讲师姓名:{self.name} 讲师年龄:{self.age} 讲师薪资:{self.salary} 讲师等级:{self.level} ')teacher_obj = teacher('egon','78','588888','888')teacher_obj.info()# # 5、班级数据与功能进行整合class grade: def __init__(self,name,area): self.name = name self.area = area def info(self): print(f'班级姓名:{self.name} 所属校区:{self.area} ')grad_obj = grade('向日葵班','上海校区')grad_obj.info()
来源:https://www.cnblogs.com/bailongcaptain/p/12655542.html