Skip to content

Instantly share code, notes, and snippets.

@gnilchee
Created January 12, 2017 02:45
Show Gist options
  • Save gnilchee/d34a62b1fa51f8221815aa33442addf8 to your computer and use it in GitHub Desktop.
Save gnilchee/d34a62b1fa51f8221815aa33442addf8 to your computer and use it in GitHub Desktop.
Simple Practice of class use and multi-line formatting return string
#!/usr/bin/env python3
class Employee:
def __init__(self, first_name, last_name, salary, position):
self.first_name = first_name
self.last_name = last_name
self.salary = salary
self.position = position
self.email = first_name + '.' + last_name + '@div.company.com'
def full_name(self):
return 'Employee:\t{} {}'.format(self.first_name, self.last_name)
def employee_email(self):
return 'Email:\t\t{}'.format(self.email)
def employee_salary(self):
return 'Salary:\t\t${:1,.2f} per annum'.format(self.salary)
def employee_full_details(self):
return 'Employee:\t{} {}\nPosition:\t{} \
\nSalary:\t\t${:1,.2f} per annum\nEmail:\t\t{}' \
.format(self.first_name, self.last_name, self.position, \
self.salary, self.email)
employee_01 = Employee('Jack', 'Smith', 75000, 'Associate Python Developer')
'''
print(employee_01.full_name())
print(Employee.full_name(employee_01))
print(employee_01.full_name())
print(employee_01.employee_email())
print(employee_01.employee_salary())
'''
print(employee_01.employee_full_details())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment