# %% Import of e.g. numpy placed here if needed # import numpy as np # %% Defintion of class Formula_1: class Formula_1(object): def __init__(self, c0, c1): self.c0 = c0 self.c1 = c1 def output(self, x): c0 = self.c0 c1 = self.c1 y = c1*x + c0 return y def rate(self): r = self.c1 return r class Formula_2(Formula_1): def __init__(self, c0, c1, c2): Formula_1.__init__(self, c0, c1) self.c2 = c2 def output(self, x): y1 = Formula_1.output(self, x) y2 = self.c2*x**2 + y1 return y2 # %% Application of class Formula_1: # Defining variables used in calling instance F2: k0 = 0 k1 = 1 k2 = 2 x = 5 # Creating instance here named F2: F2 = Formula_2(k0, k1, k2) # Calling method named output of F2: print('Output value of F2: =', F2.output(x)) # Showing data attribute c2 of F2: print('Parameter c2 of F2:', F2.c2) # Showing type of F2: print('Instance type of F2:', type(F2))