Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Employe:
- raise_amount = 2.5
- def __init__(self, fname, lname, pay):
- self.first = fname
- self.last = lname
- self.pay = pay
- def name(self):
- self.mail = self.first + '@gmail.com'
- return ('{}'.format(self.mail))
- def apply(self):
- self.total = float(self.pay) * self.raise_amount
- return ('{} '.format(self.total))
- def __repr__(self): # magic method
- return ('Employee: {} , {} , {} '.format(self.first, self.last, self.pay))
- def __str__(self): # magic method
- return ('{} - {} - {} '.format(self.name(), self.apply(), self.first))
- def __add__(self, other): # problem
- return self.pay + other.pay
- # def __len__(self): # magic method
- # return len(self.name())
- emp_1 = Employe('riju', 'chowdhury', 3000)
- emp_2 = Employe('alen', 'mok', 4000)
- print(emp_1.apply())
- print(emp_1 + emp_2)
- # print(len(emp_1))
- print(len(emp_1.name()))
- # print(int.__add__(1, 2))
- print(repr(emp_1)) # magic_method: repr()
- print(str(emp_1)) # magic_method: str()
Advertisement
Add Comment
Please, Sign In to add comment