Python123第12周作业-8题-面向对象和面向过程
1 class Pelope: 2 def xinxi(self,year,name): 3 print(name+ "," +year+ "岁,男,上山去砍柴") 4 print(name+ "," +year+ "岁,男,开车去东北") 5 print(name+ "," +year+ "岁,男,最爱打游戏\n") 6 class Son(Pelope): 7 year ="10" 8 name ="小明" 9 class Father(Pelope): 10 year ="90" 11 name ="老李" 12 son = Son() 13 son.xinxi(son.year,son.name) 14 father = Father() 15 father.xinxi(father.year,father.name)
结果: