Professional Documents
Culture Documents
Init
Init
For Example:
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
p1 = Person("John", 36)
print(p1.name)
#Output: John
Copy
Types of constructors in Python
1. The default constructor is the one that does not take any arguments.
2. Constructor with parameters is known as parameterized constructor.
Methods and functions are very similar, yet there are some differences: