0
please help me understand the part under "thispart" comment
class p_table: developer = "Humayun Kamran" #thispart # instance attribute def __init__(self, Z, M, EC): self.Z = Z self.M = M self.EC = EC #thispart H = p_table(1,1, "1s`1") He = p_table(2,4,"1s`2") print("atomic no of H is {}".format(H.Z))
4 Respostas
+ 3
This is the init method of the Class. It work like a constructor in other programming languages. It is called when you create an object of that class. In this case it takes the arguments Z M EC and asignes attributes for all arguments.
+ 1
self returns the object itself and with sellf.Z you access the attrubute Z of the object which is self points to.
I think you should take a python course since this is pretty trivia.
0
Okay... But what is "self" here... And why are we assigning self.Z to Z....????
0
Okay.. I will