# %% 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 # %% Application of class Formula_1: # Defining variables used in calling instance of class: k0 = 0 k1 = 1 x = 5 # Creating instance here named F1: F1 = Formula_1(k0, k1) # Calling method named output of F1: print('Output value y1:', F1.output(x)) # Calling method named rate of F1: print('Calculating rate coeff of formula:', F1.rate()) # Showing data attribute c0 of F1: print('Data attribute c0: ', F1.c0) # Showing type of F1: print('Instance type of F1: ', type(F1))