I am trying to Implement a child class called mathnew and parent classes as sqroot, addition, subtraction, multiplication and division. Use the super() function to inherit the parent methods.
This is the code.
from math import *
from functools import reduce
class sqroot:
def __init__(self,n1):
self.n1 = n1
def sqroot(self):
return(sqrt(self.n1))
class addition:
def __init__(self,n2):
self.n = n2
def add(self):
return(sum(self.n))
class subtraction:
def __init__(self,n3,n4):
self.n1 = n3
self.n2 = n4
def sub(self):
return((self.n1-self.n2))
class multiplication:
def __init__(self,n5):
self.n = n5
def product(self):
return((reduce(lambda x,y: x*y, self.n)))
class division:
def __init__(self,n6,n7):
self.n1 = n6
self.n2 = n7
def div(self):
return("The quotient is :- {}".format(self.n1/self.n2))
class mathnew(sqroot,addition,subtraction,multiplication,division):
def __init__(self):
super().__init__()
d1 = mathnew(4)
print(d1.sqroot(4))
I tried multiple ways but it is not working