

New derived class has the features of both base class Parent and derived class Child functions and members as its features. New derived class Grandchild is inherited from the previously derived class Child. Now this class has members has getName(), getAge() functions and its constructors. It has a function getAge() to get the age of the given children. Derived class Child is inherited from the base class Parent with its members as a constructor which is using the base class constructor to assign the name and assigning age here. We can get the name of the grandchild using this function. The parent class is a base class that has a constructor that is assigning a name, and a function getName(). In the above multilevel inheritance example, we have three classes named as Parent, Child, and Grandchild. Print(gc.getName(), gc.getAge(), gc.getLocation()) Gc = Grandchild("Srinivas",24,"Hyderabad")

Let us explain multilevel inheritance with an example as below: class Parent: In python, multilevel inheritance works as below. How Multilevel Inheritance Works in Python? In the above class example, we can see that the class base is the base class and class derived is inherited from the class base and class derived2 is inherited from the class derived1. functions of derived2 class + derived1 class + base class members of derived2 class + derived1 class + base class functions of derived1 class + base class members of derived1 class + base class The base class has its members and functions as below: class base: Let us say we have three classes with names as the base, derived1, and derived2. If we have three classes A, B, and C where A is the superclass (Parent), B is the subclass (child), and C is the subclass of B (Grandchild). By using inheritance, we can achieve the reusability of code, relationships between the classes.

While inheriting the methods and members of both base class and derived class will be inherited to the newly derived class. In python, Multilevel inheritance is one type of inheritance being used to inherit both base class and derived class features to the newly derived class when we inherit a derived class from a base class and another derived class from the previous derived class up to any extent of depth of classes in python is called multilevel inheritance. Introduction to Multilevel Inheritance in Python
