Sep 11, 2024
class Employee:
.pass
statement.employee1 = Employee()
and employee2 = Employee()
.employee1
and employee2
manually.__init__
Method__init__
method (constructor).def __init__(self, first, last, pay):
__init__
using self
keyword:
self.first = first
self.last = last
self.pay = pay
__init__
method:
employee1 = Employee('Corey', 'Schaefer', 50000)
employee2 = Employee('Test', 'User', 60000)
def full_name(self):
return f'{self.first} {self.last}'
employee1.full_name()
.self
argument in methods will raise a TypeError
.self
does not recognize instance.Employee.full_name(employee1)