Python inheritance 👪

Published: 28 December 2020
on channel: Bro Code
84,933
4.5k

Python inheritance tutorial example explained

#python #inheritance #tutorial

class Animal:

alive = True

def eat(self):
print("This animal is eating")

def sleep(self):
print("This animal is sleeping")

class Rabbit(Animal):

def run(self):
print("This rabbit is running")

class Fish(Animal):

def swim(self):
print("This fish is swimming")

class Hawk(Animal):

def fly(self):
print("This hawk is flying")


rabbit = Rabbit()
fish = Fish()
hawk = Hawk()

print(rabbit.alive)
fish.eat()
hawk.sleep()

rabbit.run()
fish.swim()
hawk.fly()

music credits 🎼 :
===========================================================
Up In My Jam (All Of A Sudden) by - Kubbi   / kubbi  
Creative Commons — Attribution-ShareAlike 3.0 Unported— CC BY-SA 3.0
Free Download / Stream: http://bit.ly/2JnDfCE
Music promoted by Audio Library    • Up In My Jam (All Of A Sudden) – Kubb...  
===========================================================


Watch video Python inheritance 👪 online without registration, duration hours minute second in high quality. This video was added by user Bro Code 28 December 2020, don't forget to share it with your friends and acquaintances, it has been viewed on our site 84,933 once and liked it 4.5 thousand people.