Advertisements
Advertisements
Question
Explain the significance of super() function.
Code Writing
Explain
Advertisements
Solution
super() is used in a derived class to access methods of its parent class, especially the parent constructor.
class Student(Person):
def __init__(self, name, roll_no):
super().__init__(name)
self.roll_no = roll_no
It avoids repeating parent-class code and is especially useful in multilevel inheritance.
shaalaa.com
Is there an error in this question or solution?
