Advertisement
Guest User

Untitled

a guest
Mar 18th, 2018
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.76 KB | None | 0 0
  1. #THIS IS A CLASS
  2. class Employee:
  3.  
  4.     def __init__(self, first, last, pay): #__INIT__ is just syntax to memorize for now and understand later
  5.         self.first=first
  6.         self.last=last
  7.         self.pay=pay
  8.         self.email = first + '.' + last + '@company.com'
  9.  
  10.     def fullname(self):
  11.         return '{} {}'.format(self.first, self.last)
  12.  
  13.     def pay(self):
  14.         return (self.pay)
  15.  
  16. #CLASSES ALLOW YOU TO DO THIS
  17. emp_1 = Employee('Core', 'Schafer', 50000)
  18. emp_2 = Employee('Test', 'User', 60000)
  19.  
  20.  
  21. #WITHOUT CLASSES YOU HAVE TO DO THIS
  22. #emp_1.first = 'Corey'
  23. #emp_1.last = 'Schafer'
  24. #emp_1.email = 'Corey.Shafer$Company.com'
  25. #emp_1.pay = 50000
  26.  
  27.  
  28. #PULL INFO FROM A CLASS INSTANCE
  29. print(Employee.fullname(emp_1))
  30. print(Employee.pay(emp_1))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement