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 18, in
File "python", line 14, in init
TypeError: can't multiply sequence by non-int of type 'float'


I don't understand why my code isn't correct, please help!


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 __init__(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)


#2

PartTimeEmployee.__init__ does not look quite right, you should read again instructions.


Error message is kind of self-explanatory. It indicates that something is wrong with the line 18:

milton = PartTimeEmployee("milton")

and 14:

return hours * 12.00

So, in line 18 you have created a new PartTimeEmployee object with "milton" as hours, quite strange, don't you think? And in the line 14 you want to multiply "milton" (hours) by 12.00 and that's the problem.


#3

Thank you, seems I made a mistake in a previous lesson but it let me pass anyways :). Thank you. This was the code that worked for me.

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

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

#4

You're very welcome :slight_smile:


#5

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