What does the __ init__ function do in python?



What does the __ init__ function do in python?..

Answer / Jai Prakash

__init__ is a special method in Python classes that gets called automatically when an object is instantiated (created). It's used to initialize the state of the object. Any code you put inside the __init__ method will be executed when you call the class with the constructors syntax.nnFor example:nnclass MyClass:n def __init__(self, name):n self.name = name

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Python Interview Questions

Why are tuples immutable?

1 Answers  


What causes static?

1 Answers  


Are methods objects in python?

1 Answers  


What is means by string python?

1 Answers  


Which software is used for python?

1 Answers  


Give an example of a shuffle() method?

1 Answers  


Is it possible to inherit one class from another class?

1 Answers  


Give one example for multiple statements in single statement?

1 Answers  


What are python iterators?

4 Answers  


What is setup py?

1 Answers  


Can you count to zero?

1 Answers  


How can you pick a random item from a list or tuple in python?

1 Answers  


Categories