Inheritance-
-Inheritance allows us to define a class that inherits all the methods and properties from another class.
Parent class-
it is the class being inherited from, also called base class.
Child class-
Child class is the class that inherits from another class, also called derived class.
Syntax-
class parent():
body
class child(parent):
body
Constructor-
-constructor is a special type of function of the class which is automatically call when the instance of the class is created.
Syntax-
def __init__(self,arg):
body
program-
#create parent class
class A():
def __init__(self):
print("Constructor of class A")
#create child class
class B(A):
def __init__(self):
print("Constructor of class B")
#create object of child class
b=B()
Constructor of class B