13/18 . Guys What is the difference?


class PartTimeEmployee(Employee):

def calculate_wage(self, hours):
    return hours * 12.00


class PartTimeEmployee(Employee):

def __init__(self,hours):

.Those codes are both true . WHat is the difference or is there any difference ? I cant understand this topic. Thanks For your help


Those are not equivalent at all, perhaps explain why you think they are?

And make sure to post intact code (marked as preformatted text in your post so that it isn't subject to markdown). Always and without excuse, but especially when you're asking us to look for details..


When I run 13/18. Both code woks . So , thats why I asked


Do you mean that both pass the exercise?

Perhaps you broke your Employee class in such a way that it behaves like PartTimeEmployee should act - meaning that you don't need to override anything. A regular Employee should get 20 wage per hour.

PartTimeEmployee should inherit everything from Employee, but override calculate_wage, because those should not be the same for both classes.


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

The third piece of instruction says: "Because PartTimeEmployee.calculate_wage overrides Employee.calculate_wage, it still needs to set self.hours = hours.", but my code works just fine when I write it as is written below. Is there something(s) I'm missing? Why would I want to use self.hours = hours ?

"""Add your code below!"""
class PartTimeEmployee(Employee):
def calculate_wage(self, hours):
return hours * 12.00


That function has no business changing anything whatsoever, it should just do a bit of math.


Oh, okay. So, it doesn't matter if do it the way Codecademy says to do it or the way I got it done? In what scenario(s) would one want to do it the way the instruction says to do it? Thanks for your replies.


Stuff should do as advertised and nothing else.

If I print "hello world" I don't want print to send a nuke somewhere. It could, but it'd be pretty bad design.


I understand now. The PartTimeEmployee would have no "hours" attribute the way I did it and I wouldn't be able to print "hours" for the instances of the PartTimeEmployee class. Thanks again for your responses.


No it would be able to do its thing for instances that have that method. But look at the arguments, how is the method supposed to be used?

bob has worked 72 hours, how much should I pay him?
bobs_salary = bob.compute_wage(72)


I know it would do its job either way. I'm saying I wouldn't be able to do something like:

print PartTimeEmployee_instance.hours

Or do I not understand you?


No clue who isn't understanding who. *shrug* happens

It's not a question of able really is it? It just shouldn't exist there, not part of the specifications.


It's okay to tweak and break rules once in a while. As long as nothing gets destroyed. :smile:


Thanks for Answer! :smile:
I thought i got the answer wrong but i just needed a def function.