+13

What is init???

In python, what is init and what is the function of it in loops?

4/8/2020 5:43:29 AM

🌼Fariha Falaq🌼

13 Answers

New Answer

+6

If you are referring to the __init__ method, this is the constructor method of Python classes, meaning it is invoked when you create an instance class and it "builds" the instance that you created using its own implementation. for example, class Cat: def __init__(self): self.name = "Sophie" new_cat = Cat() # This is where you create an instance of the Cat class, the __init__ method is invoked setting the name attribute to "Sophie". print(new_cat.name()) # This will output "Sophie" thanks to the constructor method setting this object's name to "Sophie" when the object (or instance) was created.

+10

OK, so init is a constructor which is used in python loops. I think I understood something. Thanks to Ganapathy P T and Kevin Star .😆🙏

+8

Thanks Goodwill Motaung Maswanganye for your help and thanks Hilla Sh for your hard work!❤❤

+6

Thank you Mursalatul Pallob and syed ibrahim for your help!🙏🙏🎓

+3

https://www.sololearn.com/learn/Python/2467/

+3

google it for more details. w3shool is a nice website for this .

+2

__init__, popular called dunder init(majorly because it has two underscores as a predix and suffix) is used to set up instantiation logic for each object run in a class It's like a kind of self built-in method in every class definition that runs implicitly when u instantiate an object of a class You don't have to involve this method explicitly. It calls itself to action when u run an object of a class I hope this help Fariha Falaq

+1

It is a constructor method while using in classes.

+1

i hope this will also help you https://www.sololearn.com/learn/Python/2467/

+1

initialize

+1

I thought about Linux init when seeing this. 🐧(That was supposed to be Tux)

+1

Init means initialize and it is a constructor in python.

0

Initialization refers to defining a constant or variable values that are used in the code for executing a computer program.