Jun-30-2020, 06:18 PM
(This post was last modified: Jun-30-2020, 06:28 PM by Yoriz. Edited 2 times in total.

*Edit Reason: Added code tags*)
# what is an issue in below coding , when i call child class function is return "None", Please guide us. #Thanks...

Out Put:

Please post all code, output and errors (in its entirety) between their respective tags. I did it for you this time, Here are instructions on how to do it yourself next time.

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
```

**wrote Jun-30-2020, 06:28 PM:***Yoriz*Please post all code, output and errors (in its entirety) between their respective tags. I did it for you this time, Here are instructions on how to do it yourself next time.