Multiple Inheritance In Python Is Easy!🐍
ฝัง
- เผยแพร่เมื่อ 3 ม.ค. 2025
- PLEASE LIKE AND SUBSCRIBE ITS FREE!
#beginners #tutorial #python
Check out my other videos to learn more computer science & programming concepts please :)
Code used in the video will be pinned in the comments!
Socials and other platforms:
linktr.ee/Yous...
# when a child class having multiple parent classes
class Prey:
def flee(self):
print("This animal is fleeing")
class Predator:
def hunt(self):
print("This animal is hunting")
class Rabbit(Prey):
pass
class Hawk(Predator):
pass
class Fish(Prey, Predator):
pass
rabbit = Rabbit()
hawk = Hawk()
fish = Fish()
# rabbit.flee()
# hawk.hunt()
fish.flee()
fish.hunt()
🎉🎉🎉