Python inheritance 👪

Pubblicato il: 28 dicembre 2020
sul canale di: 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...  
===========================================================


In questa pagina del sito puoi guardare il video online Python inheritance 👪 della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Bro Code 28 dicembre 2020, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 84,933 volte e gli è piaciuto 4.5 mille spettatori. Buona visione!