# %% 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 class Formula_3(Formula_2): def __init__(self, c0, c1, c2, c3): Formula_2.__init__(self, c0, c1, c2) self.c3 = c3 def output(self, x): y2 = Formula_2.output(self, x) y3 = self.c3*x**3 + y2 return y3 # %% Application of class Formula_1: # Defining variables used in calling instance F3: k0 = 0 k1 = 1 k2 = 2 k3 = 3 x = 5 # Creating instance here named F3: F3 = Formula_3(k0, k1, k2, k3) # Calling method named output of F3: print('y3 = output value of F3:', F3.output(x))