What is the __init__() method for?

Questions & AnswersCategory: PythonWhat is the __init__() method for?
Lokesh Kumar Staff asked 2 years ago

What is the __init__() method for?
a. This method is an informal representation of an object.
b. This method is a formal representation of an object.
c. This method is used to implement an iterator.
d. This method is run right after the instance is created and allows you to initialize the state of this instance (set certain attributes, validate the values of the attributes, etc.)
 

1 Answers
Lokesh Kumar Staff answered 2 years ago

d. This method is run right after the instance is created and allows you to initialize the state of this instance (set certain attributes, validate the values of the attributes, etc.)