Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Animal:
- def __init__(self, name):
- self.name = name
- def speak(self):
- print("This animal is named: " + self.name)
- print("It doesn't make a specific sound.")
- a1 = Animal("fred")
- a1.speak()
- class Dog(Animal):
- def __init__(self, name):
- super().__init__(name)
- def speak(self):
- print("This animal is named: " + self.name)
- print("It goes Arf!")
- d1 = Dog("Fido")
- d1.speak()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement