This look like a job for


#1



https://www.codecademy.com/en/courses/python-intermediate-en-WL8e4/2/4?curriculum_id=4f89dab3d788890003000096#


Traceback (most recent call last):
File "python", line 18, in
TypeError: calculate_wage() takes exactly 2 arguments (1 given)


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(self,hours)
milton = PartTimeEmployee("abdelkader")
print milton.calculate_wage()


#2

here:

print milton.calculate_wage()

how many hours did milton work? you need to supply that as argument


#3

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("abdelkader")
print milton.calculate_wage(10)

the result in the console is wrong but still i can pass to the next exercise :
120.0
None
can plz explain more ?


#4

why is the result wrong in your opinion? If you work 10 hours for 12 dollars an hour, you earned 120 dollars, so that seems right


#7

you wrote
print milton.calculate_wage(10)
instead of
print milton.full_time_wage(10)


#8

Take note of where you return value in function
it should be return self.hours * 12 and not return hours * 12. I am sure the code below will guide you.

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

class PartTimeEmployee(Employee):
def calculate_wage(self,hours):
self.hours = hours
return self.hours * 12

def full_time_wage(self,hours):
    self.hours = hours
    return super(PartTimeEmployee,self).calculate_wage(hours)

milton = PartTimeEmployee("Milton")
print milton.full_time_wage(10)


#9

Thanks, very informative. I understand the problems with my code.


#10

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.