+ 1

Need explanation anyone !

Class A def__init__(a,b,c): Print(b) A(8,3)

5th May 2020, 2:20 PM
《A$# ☆ $ING#》
《A$# ☆ $ING#》 - avatar
3 Respostas
0
What is the advantages of using init method
6th May 2020, 10:34 AM
《A$# ☆ $ING#》
《A$# ☆ $ING#》 - avatar
0
'Class' should be lower case ':' after defining the class too. Itll look like class A: When you write the __init__ method: it needs a space in between 'def' and '__init__' You also need the parameter 'self' itll look like: class A: def __init__(self,a,b,c): Then you need to assign your parameters except for 'self' like so. class A: def __init__(self,a,b,c): self.a = a self.b = b self.c = c example = A(1,2,3) print(example.b) 2
5th May 2020, 2:31 PM
Slick
Slick - avatar
0
Every time you create a new instance of a class, the __init__ method basically sets up the basic values of the instance. The advantages arent clearly seen through such a small program. But the more complex your program is, the more useful oop is going to be to you.
6th May 2020, 12:34 PM
Slick
Slick - avatar