python initialize a class

Solutions on MaxInterview for python initialize a class by the best coders in the world

showing results for - "python initialize a class"
Travis
26 Nov 2018
1class EMPLOYEE:
2    raise_amt = 1.04
3		# constructor
4    def __init__(self, first, last, pay):
5        self.first = first
6        self.last = last
7        self.email = first + '.' + last + '@email.com'
8        self.pay = pay
9
10		# methods 
11    def fullname(self):
12        return '{} {}'.format(self.first, self.last)
13
14    def apply_raise(self):
15        self.pay = int(self.pay * self.raise_amt)
16
17		def greeting(self):
18				return f'My name is {self.first} and my email is {self.email}'