Sitemap

Inheritance in Object Oriented Programming for Python

2 min readDec 26, 2022

--

Introduction

Inheritance is one of the most important aspects of Object Oriented Programming (OOP). The key to understanding Inheritance is that it provides code re-usability. In place of writing the same code, again and again, we can simply inherit the properties of one class into the other.

This, as you can imagine, saves a ton of time. And time is money in data science!

Press enter or click to view image in full size

OOP is all about real-world objects and inheritance is a way of representing real-world relationships. Here’s an example — car, bus, bike — all of these come under a broader category called Vehicle. That means they’ve inherited the properties of class vehicles i.e. all are used for transportation.

Get Team AV’s stories in your inbox

Join Medium for free to get updates from this writer.

We can represent this relationship in code with the help of inheritance.

Another intriguing thing about inheritance is that it is transitive in nature. But what does this mean? We’ll see in detail later in this article. Python also supports various types of inheritance in OOPS which I will cover in detail in this article besides covering what is inheritance in python.

What is Inheritance in Object Oriented Programming?

Inheritance is the procedure in which one class inherits the attributes and methods of another class. The class whose properties and methods are inherited is known as the Parent class. And the class that inherits the properties from the parent class is the Child class.

--

--

Team AV
Team AV

Written by Team AV

This is the Official Handle of Analytics Vidhya. In case of queries, reach out to us at editor@analyticsvidhya.com