Apr-10-2021, 06:54 PM
I am new to using classes in Python and am having a bit of trouble on my homework assignment.
Here is the assignment. It is kind of long so I put it in a pastebin.
https://pastebin.com/zsMf26nf
I am getting several errors and I am not sure what the problem is. I tried looking on StackOverflow on how to fix it but I didn't find anything very helpful. I don't know what the 0x0000 errors mean. Hopefully, someone can explain it to me because I am very confused about the issue I am having.
Here are the errors I am getting.
I am using Windows and Python 3.9.4.
Here is my code:
Here is the assignment. It is kind of long so I put it in a pastebin.
https://pastebin.com/zsMf26nf
I am getting several errors and I am not sure what the problem is. I tried looking on StackOverflow on how to fix it but I didn't find anything very helpful. I don't know what the 0x0000 errors mean. Hopefully, someone can explain it to me because I am very confused about the issue I am having.
Here are the errors I am getting.
Error:<__main__.Employee object at 0x0000022C8187BFD0>
<__main__.ProductionWorker object at 0x0000022C8187BF70>
<__main__.Employee object at 0x0000022C8187B970>
<__main__.ProductionWorker object at 0x0000022C8187BFD0>
I also was getting this error but I think I was able to fix it. I am not really sure why I was getting it because from reading it there are only 4 arguments and not 5. Error:worker_obj = ProductionWorker("Johnson White", "305", "2", "30")
TypeError: __init__() takes 4 positional arguments but 5 were given
Johnson White argument 1, 305 argument 2, 2 argument 3, 30 argument 4. Maybe someone can explain this to me because I don't understand it.I am using Windows and Python 3.9.4.
Here is my code:
class Employee (): def __init__(self, name, employee_number): self.name = name self.employee_number = employee_number class ProductionWorker(Employee): def __init__(self, name, employee_number, shift_number, pay_rate): self.name = name self.employee_number = employee_number self.shift_number = shift_number self.pay_rate = pay_rate # create an employee emp_obj = Employee("Mary Johnson", "202") # name: Mary Johnson, employee_number: 202 # create a production worker worker_obj = ProductionWorker("Johnson White", "305", "2", "30") # name: Johnson White, employee_number: 305, shift_number: 2, pay_rate: 30 # I am not sure if I am doing the print statements correctly or not # Print Mary information print(emp_obj) # Mary Johnson 202 # Print Johnson Information print(worker_obj) # Johnson White 305 2 30 # update Mary Information emp_obj = Employee("Mary Smith", "202") # print Mary updated information print(emp_obj) # Mary Smith 202 # update Johnson name to Jason and pay to 32 worker_obj = ProductionWorker("Jason White", "305", "2", "32") print(worker_obj) # Jason White 305 2 32