What is the role of the __init__ method in a Python class?
Correct answer C. It initialises a newly created instance, typically setting its attributes
Explanation
__init__ is called automatically after an instance has been created, with arguments passed to the class call, and is used to set up initial state such as self.name = name. Creating the object is done by __new__, and __init__ must return None. Clean-up near destruction is __del__.
Answer checked How we write and check questions
Discussion