In this we are going to see a program on Use of super() Python to Access both Constructor and Methods of Base Class - 2 in Python Programming Language.
class Teacher:
def __init__(self, id, name, place):
self.id = id
self.name = name
self.place = place
def display(self):
print(f"Id:{self.id}\nName:{self.name}\nPlace:{self.place}")
class Student(Teacher):
def __init__(self, id, name, place, marks):
super().__init__(id, name, place)
self.marks = marks
def display(self):
super().display()
print(f"Marks:{self.marks}")
s = Student(1, "Ramu", "Mumbai", 25)
s.display()
# Coded by Saahil
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP