Super Keyword in Python

Super Keyword in python:
  • The super keyword in Python is used to call methods from a parent (or superclass) inside a child (or subclass). 
  • It allows for method overriding and inheritance while ensuring that the parent class’s methods are properly executed.

Basic Example of super :

Program :




Output :






Using super with __init__ Method :
  • When a child class has an __init__ method, super().__init__() helps initialize the parent class constructor.

Program :




Output :




Using super in Multiple Inheritance :
  • In multiple inheritance, super() follows the Method Resolution Order (MRO).

Program :



Output :




Post a Comment

0 Comments