Python super() Function
Master Python with 70+ Hands-on Projects and Get Job-ready - Learn Python
Program 1
#Super method in python
# class A:
# def __init__(self):
# print("A")
# class B(A):
# def __init__(self):
# super().__init__()
# print("B")
# class C(B):
# def __init__(self):
# super().__init__()
# print("C")
# A1=A()
# print("-------------")
# B1=B()
# print("-------------")
# C1=C()
#Multiple Inheritance
# class A(object):
# def __init__(self):
# super().__init__()
# print("A")
# class B(object):
# def __init__(self):
# super().__init__()
# print("B")
# class C(B,A):
# def __init__(self):
# super().__init__()
# print("C")
# #Calling (Main)
# C1=C()
# class Student:
# def __init__(self,rno,name,email):
# self.rno=rno
# self.name=name
# self.email=email
# class Result(Student):
# def __init__(self,rno,name,email,hindi,maths,comp,eng):
# super().__init__(rno,name,email)
# self.hindi=hindi
# self.maths=maths
# self.comp=comp
# self.eng=eng
# def display(self):
# print(self.rno)
# print(self.name)
# print(self.email)
# print(self.hindi)
# print(self.maths)
# print(self.comp)
# print(self.eng)
# #Calling
# rn=int(input("Enter Roll No"))
# nm=input("Enter Name")
# em=input("Enter Email Id")
# h=int(input("Enter Hindi Marks"))
# m=int(input("Enter Maths Marks"))
# c=int(input("Enter Computer Marks "))
# e=int(input("Enter English Marks "))
# R=Result(rn,nm,em,h,m,c,e)
# R.display()
class First:
def addition(self,a,b):
return(a+b)
class Second(First):
def addition(self,a,b,c,d):
print(super().addition(a,b))
return(a+b+c+d)
S=Second()
print(S.addition(50,20,60,70))
Your 15 seconds will encourage us to work even harder
Please share your happy experience on Google

