Skip to content

Instantly share code, notes, and snippets.

@saraswatmks
Created January 13, 2018 11:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saraswatmks/106207c37c21069fae27b12f155e1c0b to your computer and use it in GitHub Desktop.
Save saraswatmks/106207c37c21069fae27b12f155e1c0b to your computer and use it in GitHub Desktop.
Derived class from Base Class inheriting same methods - Python
class Employee(object):
"""Models real-life employees!"""
def __init__(self, employee_name):
self.employee_name = employee_name
def calculate_wage(self, hours):
self.hours = hours
return hours * 20.00
# Add your code below!
class PartTimeEmployee(Employee):
def calculate_wage(self, hours):
self.hours = hours
return hours * 12.00
def full_time_wage(self, hours):
return super(PartTimeEmployee, self).calculate_wage(hours)
milton = PartTimeEmployee('Milton')
print milton.full_time_wage(10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment