Python inheritance 👪

preview_player
Показать описание
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()

music credits 🎼 :
===========================================================
Creative Commons — Attribution-ShareAlike 3.0 Unported— CC BY-SA 3.0
===========================================================
Рекомендации по теме
Комментарии
Автор

Don't forget to SMASH that LIKE button and
DROP a random COMMENT down below for the YT algorithm
🙏

also here's the code from the video...
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()

BroCodez
Автор

i watched like 3 videos read 2 books about inheritance listened 1 lecture and learnt nothing. then you came up with 7 minute video and just put knowledge in my brain <3 <3

incognito
Автор

You have no idea how well you just described this. Thank you, much needed.

cameron
Автор

what you do is not teaching, it's more like magic you rock!

tara
Автор

This is the best programming series I have ever seen. You have a great gift for teaching.

ronbelanger
Автор

Whoa, how on earth can you make me understand inheritance in a 7-minute video but my class of 7 lecture videos couldn't?! lol Good-looking Bro, I always refer to you for learning and in a rut in school during my Python phase. Now we're moving into Phase 2 with Django and Full Dev Stack stuff!

DucTaZenSurfer
Автор

That was great, concise, informative and interesting! Thank you very much.

francismannion
Автор

Easily and clearly explained. Thanks :)

snoopy
Автор

Extremely easy and useful tutorial. I am studying django and a lot of things are just making sense now! Great Content!

thalesaragao
Автор

I saw 44 seconds and instant thumb up. Im gonna suscribe.

gregoriolobato
Автор

this is the only tutorial that has actually made me understand class inheritance. thank you so much! subscribed 👓

cameronestrada
Автор

My head was exploding figuring out this whole inheritance problem, thank you so much for being a big brother and saving me.!😭😭

hari
Автор

Going to school for Cyber Security Management and taking a program class! Professor put this video in resources. I will def save and come back! Thank you for explaining this!

sarakopser
Автор

This is more useful than the semester worth classes.

talhaomair
Автор

-thank you for this clear explanation!

istein
Автор

Thanks for explaining things in an easy way. Very helpful. Liked and Subscribed <3

utkarshpateriya
Автор

Nice, thanks. So we would only initialise if we wanted to list attributes, but because we were focused on methods we didn't have to?

sattamassagan
Автор

This was extremely helpful, thank you

raidenx_knights
Автор

i hope you are making lots of money through advertisements, cos you are helping us computing students a lot!!

NeoWaiTengTildaTemasekjc
Автор

Bro, you're the best programming mentor on earth
Love you

shamaeelahmed