Open In App

Multilevel Inheritance in Python

Last Updated : 10 Sep, 2025
Comments
Improve
Suggest changes
8 Likes
Like
Report

Multilevel inheritance in Python means a class (child) inherits from a parent class and then another class (derived) inherits from that child class, forming a chain of classes one after another.

Example:

  • Class A -> Parent (Base class)
  • Class B -> Inherits from A (Child class)
  • Class C -> Inherits from B (Derived class)

Here, Class C can use the features of both Class A and Class B. It’s like a family chain: Grandparent -> Parent -> Child.

Diagram for Multilevel Inheritance

Multilevel Inheritance in Python

Let's look at some examples below:

Example 1: Simple Multilevel Inheritance

This is a simple example of multilevel inheritance, where the Child class inherits from the Parent class and the Parent inherits from the Grandparent class.

Python
class Grandparent:
    def fun1(self):
        print("I am the Grandparent.")

class Parent(Grandparent):
    def fun2(self):
        print("I am the Parent.")

class Child(Parent):
    def fun3(self):
        print("I am the Child.")

obj = Child()
obj.fun1()
obj.fun2()
obj.fun3()

Output
I am the Grandparent.
I am the Parent.
I am the Child.

Example 2: Multilevel Inheritance with Overriding

This example shows multilevel inheritance with method overriding using the Emp, Manager and ProjManager classes.

Python
class Emp:
    def work(self):
        print("Employee works.")

class Manager(Emp):
    def work(self):
        print("Manager manages.")

class ProjManager(Manager):
    def work(self):
        print("Project Manager plans.")

obj = ProjManager()
obj.work()

Output
Project Manager plans.

Explanation:

  • Emp: it's a Base class, defines a general work () method.
  • Manager: it's a Child class, inherits from Emp class and overrides work () method.
  • ProjManager: it's a Derived class (final class), inherits from Manager class and overrides work () method again.
  • obj = ProjManager(): creates an object of the derived class.
  • obj.work(): calls the overridden method from the ProjManager class.

Related Articles:


Explore