1. Create a Cat class
Write code Easy ✓ CompletedCreate a class Cat that inherits from Animal and overrides speak() so it returns "<name> says meow" — for example "Tom says meow". Do not change Animal.
class Animal:
def __init__(self, name):
self.name = name
def speak(self):
return f"{self.name} makes a sound"
# create class Cat here
kitty = Cat("Tom")
print(kitty.speak())
class Cat(Animal): and define only speak(self). The __init__ from Animal is inherited automatically.class Animal:
def __init__(self, name):
self.name = name
def speak(self):
return f"{self.name} makes a sound"
class Cat(Animal):
def speak(self):
return f"{self.name} says meow"
kitty = Cat("Tom")
print(kitty.speak())