+ 1

please explain me the use of __init__ !! im not getting it!! please provide an example also and tell me why is it necessary!!

please explain me the use of __init__ !! im not getting it!! please provide an example also and tell me why is it necessary!!

16th May 2020, 5:32 AM
Lucious Erudite
Lucious Erudite - avatar
3 Answers
0
Use the __init__() function to assign values to object properties, or other operations that are necessary to do when the object is being created: Example Create a class named Person, use the __init__() function to assign values for name and age: class Person: def __init__(self, name, age): self.name = name self.age = age p1 = Person("John", 36) //John //36 Note:Ā TheĀ __init__()Ā function is called automatically every time the class is being used to create a new object.
16th May 2020, 5:42 AM
ā£š“†© AnŠŗĪĻ„ soā„“ąø„nŠŗĪ ā™£ļø
ā£š“†© AnŠŗĪĻ„ soā„“ąø„nŠŗĪ ā™£ļø - avatar
0
thank you enemy!!
16th May 2020, 5:57 AM
Lucky Nayak
Lucky Nayak - avatar
0
hey john answer my new question
19th May 2020, 8:17 AM
Lucious Erudite
Lucious Erudite - avatar