-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinheritance.py
More file actions
39 lines (39 loc) · 1.02 KB
/
Copy pathinheritance.py
File metadata and controls
39 lines (39 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
class animal:
def __init__(self,name):
self.name=name
def eat(self):
print(f"{self.name} is eating")
def sleep(self):
print(f"{self.name} is sleeping")
class dog(animal):
def __init__(self,name,breed):
super().__init__(name)
self.breed=breed
def bark(self):
print(f"The {self.name} (a{self.breed}) barks:Woof! Woof!")
class cat(animal):
def __init__(self,name,color):
super().__init__(name)
self.name=name
self.color=color
def meow(self):
print(f"{self.name} (a{self.color}) cat meows: Meow!")
class bird(animal):
def __init__(self,name,species):
super().__init__(name)
self.name=name
self.species=species
def fly(self):
print(f"{self.name} (a{self.species}) is flying high!")
my_dog=dog("bobo","chihuahua")
my_cat=cat("meme","bobtail")
my_bird=bird("caca","crow")
my_dog.eat()
my_dog.bark()
my_dog.sleep()
my_cat.eat()
my_cat.meow()
my_cat.sleep()
my_bird.eat()
my_bird.fly()
my_bird.sleep()