Python Tutorial
About Lesson

In this lesson we want to learn about Python Method Overriding, by using method overriding we can change the implementation of a method provided by one of it is base class.

 

Now let’s create a practical example.

 

So in the above example we have two classes, the first class is our Person Class and it is our base class, also we have added a method of def print_name() in this class, on the other hand we have another class at name of Student class and this class is extending from the base class, so for this we can say that it is a derived class, now you can see that we have the same name method in our derived class, when you have two methods with the same name and different implementation that is called Method Overriding.

 

 

If you run the code you can see that we have different implementation for the same method name.

Python Method Overriding
Python Method Overriding

 

Thank you for visiting my website! If you enjoyed the free courses, please consider supporting my works on Patreon.
Exercise Files
No Attachment Found
No Attachment Found