Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Animal:
- name = None
- color = None
- def __init__(self, name, color):
- self.name = name
- self.color = color
- def makeSound(self, sound):
- return f"{self.name} is {sound}"
- def eat(self, food):
- return f"{self.name} is eating {food}"
- dog = Animal("Dog", "Black")
- cat = Animal("Cat", "Yellow")
- bird = Animal("Bird", "White")
- print(dog.name)
- print(dog.color)
- print(dog.makeSound("Barking"))
- print(dog.eat("meat"))
- print(cat.name)
- print(cat.color)
- print(cat.makeSound("Meowing"))
- print(cat.eat("fish"))
- print(bird.name)
- print(bird.color)
- print(bird.makeSound("Chirping"))
- print(bird.eat("fruit"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement