FAQ: Learn Python - Introduction to Classes - This Looks Like a Job For

This community-built FAQ covers the “This Looks Like a Job For…” exercise in Codecademy’s lessons on Python.

FAQs for the Codecademy Python exercise This Looks Like a Job For…:

Join the Discussion. We Want to Hear From You!

Have a new question or can answer someone else’s? Reply (reply) to an existing thread!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources about Python in general? Go here!

Want to take the conversation in a totally different direction? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account, billing, Pro, or Pro Intensive? Reach out to our support team!

None of the above? Find out where to ask other questions here!

Other FAQs

The following are links to additional questions that our community has asked about this exercise:

  • This list will contain other frequently asked questions that aren’t quite as popular as the ones above.
  • Currently there have not been enough questions asked and answered about this exercise to populate this FAQ section.
  • This FAQ is built and maintained by you, the Codecademy community – help yourself and other learners like you by contributing!

Not seeing your question? It may still have been asked before – try searching for it by clicking the spyglass icon (search) in the top-right of this page. Still can’t find it? Ask it below by hitting the reply button below this post (reply).

My code is this:

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("Milton")
print milton.full_time_wage(8)

I’m getting this error:

Traceback (most recent call last):
File “python”, line 19, in
File “python”, line 16, in full_time_wage
TypeError: calculate_wage() takes exactly 2 arguments (3 given)

What am I doing wrong?

1 Like

Hi @arraysolver16164,

The problem is with this line in the full_time_wage method of PartTimeEmployee:

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

Within that line, super(PartTimeEmployee,self) serves as an object that represents an instance of PartTimeEmployee that behaves as an instance of its superclass, Employee. This is done so that you can access the calculate_wage method of Employee instead of the method of the same name that is defined for PartTimeEmployee, effectively enabling the instance of PartTimeEmployee to collect wages at the Employee rate, whenever circumstances arise that merit that arrangement. Just as with a call to the calculate_wage method from an instance of Employee, we need to omit the argument corresponding to self, and pass only one explicit argument corresponding to the hours parameter. The object from which the method is called implicitly becomes the argument corresponding to self. Here, that object is super(PartTimeEmployee,self). Taking all of this into consideration, the problematic line should be changed to:

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

This post was edited on July 31, 2019 to make minor adjustments to the wording.

5 Likes

return super(PartTimeEmployee, self).calculate_wage(hours).
try this , that means you don’t have to introduce self with hours