This Looks Like a Job For… Help please!


Why cannot this code pass?
I changed the last code into: print milton.full_time_wage(4)
Then changed to return super(PartTimeEmployee, self).calculate_wage(hours)
Then I can pass.
But I don't understand why.
The following is my original code:

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):
        return hours*12.00
    def full_time_wage(self, hours):
        return super(PartTimeEmployee, self).calculate_wage(self,hours)

print full_time_wage(milton,4)


full_time_wage only takes in one input (AKA parameter). You seem to have tried to put in two here:

Hours should be 10 and not 4 fyi (from instructions).


Thank you. But I get confused about the "self". When do we need it and when do we only need other parameters, eg. hours?

It seems here that the full_time_wage function only needs hours.
But a similar function calculate_wage would require a "self" in its parameter.
Why is it this case?


print full_time_wage(milton,4)

Since datfatat already addressed the arguments, to call a class on a variable we use the format:

print variable.class(arg)

Here is more on classes:


It is very helpful. Thank you very much.


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