15 lines
284 B
Python
15 lines
284 B
Python
class Dog:
|
|
def speak(self):
|
|
return "Woof!"
|
|
|
|
class Cat:
|
|
def speak(self):
|
|
return "Meow!"
|
|
|
|
def animal_sound(animal):
|
|
return (animal.speak())
|
|
|
|
print(f" My dog says, {animal_sound(Dog())}") # Woof!
|
|
print(f" My cat says, {animal_sound(Cat())}") # Meow!
|
|
|