class School_number():
def __init__(self, name, age):
self.name = name
self.age = age
def describe(self):
print(f"我的名字是{self.name},我的年龄是{self.age}")
class Student(School_number):
def __init__(self, name, age, sex):
School_number.__init__(self, name, age)
self.sex = sex
def describe(self):
super().describe()
print(f"我的名字是{self.name},我的年龄是{self.age},性别是{self.sex}")
student = Student("张三", 18, "男")
student.describe()
class Person():
def say_hello(self):
print("打招呼")
class Chinese(Person):
def say_hello(self):
super().say_hello()
print("你好")
chinese = Chinese()
chinese.say_hello()
class Animal():
def speak(self):
pass
class Dog(Animal):
def speak(self):
print("小狗汪汪叫")
class Cat(Animal):
def speak(self):
print("小猫喵喵叫")
class Chicken(Animal):
def speak(self):
print("小鸡唧唧叫")
# dog = Dog()
# dog.speak()
# cat = Cat()
# cat.speak()
def animal_speak(animal):
animal.speak()
dog = Dog()
animal_speak(dog)
cat = Cat()
animal_speak(cat)
© 版权声明
THE END
暂无评论内容