When a subclass inherits from a superclass, must the subclass have all the arguments that the superclass has? E.g.: "Vehicle(colour, wheels, size)" is the superclass. Can I have a subclass that inherits everything from Vehicle except the "size" attribute/argument?
This is the parent class:
class LagStudent:
def __init__(self, name, dept, cgpa, is_a_scholar):
self.name = name
self.dept = dept
self.cgpa = cgpa
self.is_a_scholar = is_a_scholar
Below are two subclasses:
class CovStudent(LagStudent):
def __init__(self, name, dept, cgpa, is_a_scholar, honours):
super().__init__(name, dept, cgpa, is_a_scholar)
self.honours = honours
class OxStudent(CovStudent):
def __init__(self, name, dept, cgpa, is_a_scholar):
super().__init__(name, dept, cgpa, is_a_scholar)
When I run the following...
student4 = OxStudent("Mark", "Mathematics", 4.62, True)
print(student4.is_a_scholar)
It gives Error:
TypeError: init() missing 1 required positional argument: 'honours'
Vehiclemethods as they requiresizeas arg.SubVehicle(Vehicle)with__init__(colour, wheels)overridden that setsself.sizeto some neccesary value.OxStudentinherit fromCovStudenthere and notLagStudent?