So I'm currently learning about python's inheritance for one of my classes and the assignment has us use multiple inheritances for the ScientificSwimmer Class. When you try to run the code without creating an object of said class the program runs. However, when creating an object of that class I get the error below. Any advice or solutions would be greatly appreciated. (Line numbers added in post)
#creation of Human class
class Human:
def __init__(self, name, age): #talks a name and balance and creates a instance of class
self.age = age
self.name = name
def hobby(self):#Hobby method
print("Likes to watch Netflix")
def info(self):#info method
print(self.name, " is ", self.age, " years old.")
#creation of the Scientist class
class Scienctist(Human):
def __init__(self, name, age, lab):
super().__init__(name, age)
self.lab = lab
def hobby(self):
print("Likes watching Bill Nye the science guy.")
def labName(self):
print("Works at the ", self.lab , "laboratory.")
#Creation of Swimmer Class
class Swimmer(Human):
def __init__(self, name, age, hours):
(line 33)super().__init__(name, age)
self.hours = hours
def hobby(self):
print("Likes to go swimming in the lake.")
def SwimmingHours(self):
print("Swims ", self.hours, "hours per week.")
#Creation of the ScientificSwimmer
class ScientificSwimmer(Scienctist, Swimmer):
def __init__(self, name, age, lab, hours):
(line 58)Scienctist.__init__(self, name, age, lab)
Swimmer.__init__(self, name, age, hours)
(line 66) person5 = ScientificSwimmer("John Smith", "30", "nuclear", "100")
Error:
File "E:\Python\CS112\lab7\People.py", line 66, in <module>
person5 = ScientificSwimmer("John Smith", "30", "nuclear", "100")
File "E:\Python\CS112\lab7\People.py", line 58, in __init__
Scienctist.__init__(self, name, age, lab)
File "E:\Python\CS112\lab7\People.py", line 33, in __init__
super().__init__(name, age)
TypeError: __init__() missing 1 required positional argument: 'hours'