python>>self and __init__
class Employee():
no_of_leave=8
def __init__(self, aname, arole, asalary):
self.name=aname
self.role=arole
self.salary=asalary
def printdetails(self):
return f"Name is {self.name}, his role is {self.role} and salary is {self.salary} "
manu=Employee("Manan", "Manager", 50000)
chanu=Employee("Manan", "Engineer", 70000)
# manu.name="Manan"
# manu.role="Manager"
# manu.salary=50000
chanu.name="Ketan"
chanu.role="Engineer"
chanu.salary=70000
print(manu.salary,manu.no_of_leave, manu.name)
print(manu.__dict__)
print(chanu.__dict__)
print(manu.)
Comments