What students Say?
Here are the stdudents...
super() can be used to call the parent’s method inside the child’s overridden method.
class Parent:
def show(self):
print("This is the Parent class method")
class Child(Parent):
def show(self):
print("This is the Child class method (Overridden)")
c = Child()
c.show() # Output: This is the Child class method (Overridden)
class Parent:
def show(self):
print("Parent class method")
class Child(Parent):
def show(self):
print("Child class method starts...")
super().show() # Calls parent method
print("Child class method ends...")
c = Child()
c.show()
# Output:
# Child class method starts...
# Parent class method
# Child class method ends...
class BankAccount:
def interest_rate(self):
return 5 # Default interest rate
class SavingsAccount(BankAccount):
def interest_rate(self):
return 7 # Higher interest rate
sa = SavingsAccount()
print(sa.interest_rate()) # Output: 7
class A:
def display(self):
print("Class A")
class B(A):
def display(self):
print("Class B")
class C(A):
def display(self):
print("Class C")
class D(B, C):
pass
obj = D()
obj.display() # Output: Class B (MRO: D -> B -> C -> A)
print(D.mro()) # Shows Method Resolution Order
Here are the stdudents...
Empower your tech dreams with us. Get in touch!




