Biton is one object oriented programming language, so it supports inheritance.
So this video will be will be discussing what is Python inheritance?
So it refers to defining a new class with little or no modification to an existing class, so a new
class will get created from the existing class with the with some changes, or it may not be having
any change at all.
That new class is called the derived class, also known as the child class and the class from which
one of the classes from which it inherits will be known as a base class or the parent class.
So just consider this one.
We are having multiple different types of inheritances.
How many types of inheritance are there?
So five types up.
What is the first one?
There is a single inheritance.
Means what means one best class and one derived class.
So that is known as a single inheritance.
So here you are having the multiple inheritance.
What does it mean?
Will it be having multiple best classes?
Not only do we can have more than two also will be having multiple classes, but one direct class.
So this particular class will inherit the properties from all the best classes.
This is our hierarchical inheritance.
Only one best class and multiple derived classes here have shown three different classes.
It may be two also.
It may be five or six, maybe seven.
Also here to having the middle level inheritance.
What is the meaning of this multilevel inheritance?
So this is the best class.
There is a direct class and for the C being the best class and sees the direct class here when having
this hybrid inheritance, what does it mean?
What is the meaning of this hybrid inheritance?
So here you see this is a one best class.
These are the direct classes.
And now for this D, this B and C are the best classes and these the direct class.
So that is known as that is known as hybrid inheritance.
So it is actually nothing, but it is hierarchical, multiple inheritance, it is hierarchical, multiple
inheritance in the soil.
Also you can have another combination that is that is of a multiple and hierarchical inheritance.
So from multiple based classes, one day class and from one class to the multiple derived classes.
So that can also happen.
That is known as multiple hierarchical inheritance.
So here to discuss what are the different types of inheritance, as are there.
So let us go for one practical demonstration.
For the better understanding in decision, we shall discuss inheritance and polymorphism, which will
be observed in Python in object oriented programming here to define one class.
So here you have defined one class.
The name of the class is my word.
This is the constructor.
These are what type?
That is one method and can swim is another method.
The method.
What is up.
It is simple.
We have just put one step statement there and here we are having another class that is known as my pinguin,
which is inheriting my board.
C my my word you have defined here.
So let me.
So here the class has been defined and my pinguin is inheriting my part.
So like of a java here we need to write extensor or any other key words just within this bracket were
mentioning the respective classes in the classroom which will be mentioned within this bracket, will
be known as a base class, also known as a super class.
And this is our direct class or subclass here.
So in case of Python, the class inheritance will be written using this particular syntax.
So this my penguin is having the respective constructor and here you are calling the best class constructor.
So this class will be called by the super method and it's constructor is always understood, understood
and understood, understood method.
So that is a Bicyclers constructor calling and then one statement to get printed and who is this and
can can run.
So these are the other two methods in this might be in Greenglass.
So just remember in my board, along with the constructor, we are having what type and can swim.
And in case of my pinguin we're having this constructor and along it we are having who is this and can
run.
So these two other methods are there, but defining one pinguin class object.
So it has been defined in a very simple way.
So that means we are having this my pinguin and then we are having the p.g.
One is the object name.
So we.
You want what type.
This particular what type was defined in the class.
That is my part as my has got inherited into my pinguin.
So my word methods can be accessed from this might be an object.
So that's why you want what type can be executed.
But having p.g one having B.G. one dot.
Who is this.
So it is defined in case of my pinguin you can easily find in my opinion who is this is defined.
But having this p.g one dot can see it having p.g one dot can run did you can see was defined in my
word class and p.g.
One dot can run.
This can can run was defined.
It might be.
That is what type and can swim we are inheriting.
We're getting this one from the best class that is my bird, because there they were defined.
So now let me go for the execution my class constructed is executing my penguin class constructor is
executing.
You can easily find that here you have called the Bicyclers constructor.
So that's why the control has gone to this.
So my world class constructor is executing has got printed at first, then my Pinguin class constructor
is executing.
So that string has got printed.
So now we called.
What type.
So what type is having the string that is ironbound.
So that has to be printed.
That has got printed.
I'm pinguin.
So now next method we call this who is this.
So I am pinguin.
So that string has got printed next we went for this can seem so consumers having this string to be
printed that is I can swim so I can swim has got printed.
Now we are having this can run and I can run faster.
So in this way this particular string has got printed.
So using this example we have shown you how inheritance can be implemented in Python.
So let us go for another example here.
But having one class, the name of the class is my Barat.
And here we are having can fly and can swim.
So obviously Barat can fly so bird can fly, but parrot cannot seem so parrot can't swim.
I'm having another class that is my penguin which is having to make the same simply because I easily
find that they can fly self and they can swim self.
So you see we're having the same problem different here also.
OK Narcy so diff can fly itself so Pinguin cannot fly and they can swim self-aware, having penguins
can swim.
So now we are having one common interface that is flying bird test.
OK, so I'm going for this bird that can fly and also Bertaud can swim.
So here in this particular method, we're just passing this part as input parameter and we are calling
this board that can fly and Bertaud can seem.
So here we have to find one class object, my class object, and one might be in class object.
So we're calling this flying test.
We're calling this flying test with this birthparent that is which is a class object and part penguin,
which is a penguin class object.
So what will happen when we are passing this birthparent?
So that is a better class object.
So that particular subject that can fly and class object that can you get executed.
So as a result of that, this can fly and this can swim, the respective body will get executed and
respective strings are going to get printed.
But when we were passing this board, Pinguin, which is the MIT penguin class object as input parameter
to this flying test.
So in that case, this board can fly and Bart can swim, will be operated on, this being my being in
class objects.
So in that case, what will happen regarding this?
Penguin cannot fly and penguins can swim in case of flying.
But this part penguin, I think is off flying.
But this parrot would have been better, can fly and parrot cannot see him.
So you can find that how these classes are having their respective objects and objects are being passed
to this flying test and respectively, the respective can fly and can see method will get executed.
So in this particular session, we have discussed what is the how to implement inheritance, how to
do the polymorphism in our python, in what object oriented programming.
Thanks for watching this video.