Python Program using the parameterized constructor
In this program, you will learn how to implement the parameterized constructor in Python.
def __init__(self, name):
//statement
Example: How to implement the parameterized constructor in Python
class Test:
def __init__(self, name):
print("Parameterized constructor is called here")
self.name = name
def show(self):
print("Your name is:", self.name)
obj1 = Test("John")
obj1.show()
Output:
Parameterized constructor is called here
Your name is: John