# what is an issue in below coding , when i call child class function is return "None", Please guide us. #Thanks...
Out Put:
import math class Calculator: """ A class is defined for calculator, to preform addition,subtration,multiplication,divison,power and exponent. """ def __init__(self,num1,num2): try: assert type(num1) == int assert type(num2) == int except AssertionError: print('Invalid parameter type') raise Exception self.num1 = num1 self.num2 = num2 def addition(self): #pdb.set_trace()# we have added a breakpoint here. The code pause execution here. #print(' Addition') return (self.num1 + self.num2) def subtraction(self): return(self.num1 - self.num2) def division(self): return(self.num1 / self.num2) def moduler(self): return(self.num1 // self.num2) def multiplication(self): return(self.num1 * self.num2) def power(self): return(self.num1 ** self.num2) class ScientificCalculator(Calculator): #parent class refrence Calculator def __init__(self,num1,num2,number,exponent): #should be initialize this function __init__() super().__init__(num1,num2) # super() will refer paranent class variables self.number = number self.exponent = exponent def logg(self): #pdb.set_trace() #we have added a breakpoint here. The code pause execution here. math.log(self.number,self.exponent) cal= Calculator(num1 = 2,num2 = 2) print('addition',cal.addition()) sci_cal = ScientificCalculator(num1=1,num2=2,number = 100,exponent = 3) print('log:',sci_cal.logg())--------------------------------
Out Put:
Output:addition 4
log: None