Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #THIS IS A CLASS
- class Employee:
- def __init__(self, first, last, pay): #__INIT__ is just syntax to memorize for now and understand later
- self.first=first
- self.last=last
- self.pay=pay
- self.email = first + '.' + last + '@company.com'
- def fullname(self):
- return '{} {}'.format(self.first, self.last)
- def pay(self):
- return (self.pay)
- #CLASSES ALLOW YOU TO DO THIS
- emp_1 = Employee('Core', 'Schafer', 50000)
- emp_2 = Employee('Test', 'User', 60000)
- #WITHOUT CLASSES YOU HAVE TO DO THIS
- #emp_1.first = 'Corey'
- #emp_1.last = 'Schafer'
- #emp_1.email = 'Corey.Shafer$Company.com'
- #emp_1.pay = 50000
- #PULL INFO FROM A CLASS INSTANCE
- print(Employee.fullname(emp_1))
- print(Employee.pay(emp_1))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement