14. This Looks Like a Job For


#1



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


Traceback (most recent call last):
File "python", line 20, in
TypeError: full_time_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(hours)
            
milton = PartTimeEmployee("Qasim")
print milton.full_time_wage()

Replace this line with your code.


#2

Hi, @youngq ,

In the instructions ...

Finally, print out the result of calling his full_time_wage method. You should see his wage printed out at $20.00 per hour! (That is, for 10 hours, the result should be 200.00.)

You have this ...

print milton.full_time_wage()

How many arguments should the full_time_wage method be given? Which argument is the one that was reported here? ...

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

#3

I think at least 2 arguments


#4

The message reports that one argument was given. That is the instance, milton, on which you called the method, which is represented by within the method by the self variable. So, now you need to supply one more piece of information within the parentheses. What additional information does the method need to be given in order to perform the calculation?


#5

is it 'calculate_wage'?


#6

The full_time_wage method has already been informed by this line that it needs to call the superclass's calculate_wage method ...

return super(PartTimeEmployee, self).calculate_wage(hours)

However, in doing so, the full_time_wage method needs to have a particular piece of information to pass to the calculate_wage method. When calling the full_time_wage method, you need to supply it with that information. This is the header of the method that you are calling ...

def full_time_wage(self,hours):

Within your method call, self is already taken care of by the fact that you called the method on the milton object. That connects milton to self. But by leaving the parentheses empty in your method call, you have not informed the method regarding how many hours milton has worked.


#7

Is this what you mean?

'print milton.full_time_wage(10)'


#8

Try it out to see what happens ...


#9

I did... it had gave me this error:

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


#10

@youngq ,

Make sure all your code is exactly the same as what you posted originally, except for that last line, which you were planning to change to this ...

print milton.full_time_wage(10)

If you do it that way, it should work.


#11

yeah sorry, i had changed it back to how it was... It works now thanks!!!


#12

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