python怎么写啊

定义三个Animal、Bird和Dog类,Animal为父类,Bird和Dog类继承自Animal。
在Animal类中包含属性leg_count,定义一个构造函数用于初始化leg_count字段;
在Bird类的构造方法中增加颜色color属性,同时调用父类构造方法继承动物的leg_count属性;
在Animal类中,定义Shout(),输出“动物叫声”;在Bird类和Dog类中重载Shout()方法,输出“鸟的叫声是喳”和“狗的叫声是汪”;
创建bird对象,初始化值为(color为“白色”,leg_count为2),输出bird对象,然后调用Shout()方法; 创建dog对象,调用Shout()方法,

class Animal:
    def __init__(self, leg_count):
        self.leg_count = leg_count

    def Shout(self):
        print("动物叫声")

class Bird(Animal):
    def __init__(self, leg_count, color):
        super().__init__(leg_count)
        self.color = color

    def Shout(self):
        print("鸟的叫声是喳")


class Dog(Animal):
    def Shout(self):
        print("狗的叫声是汪")


bird = Bird(2, "白色")
print(bird)
bird.Shout()

dog = Dog(4)
dog.Shout()

在这段代码中,Animal 类是父类,它具有一个 leg_count 属性和一个 Shout() 方法。Bird 和 Dog 类分别继承自 Animal 类,并在其构造方法中调用了父类的构造方法来继承 leg_count 属性。Bird 类还增加了一个 color 属性。
在 Animal 类中,Shout() 方法输出"动物叫声"。在 Bird 和 Dog 类中,Shout() 方法被重载,分别输出"鸟的叫声是喳"和"狗的叫声是汪"。
运行以上代码,得到以下输出:

鸟的叫声是喳
狗的叫声是汪
class Animal:
    def __init__(self, leg_count):
        self.leg_count = leg_count

    def Shout(self):
        print("动物叫声")

class Bird(Animal):
    def __init__(self, leg_count, color):
        super().__init__(leg_count)
        self.color = color

    def Shout(self):
        print("鸟的叫声是喳")

class Dog(Animal):
    def Shout(self):
        print("狗的叫声是汪")

bird = Bird(2, "白色")
print(bird.color)
print(bird.leg_count)
bird.Shout()

dog = Dog(4)
dog.Shout()