#%% Class def class Inventory: # Class constructor: def __init__(self, n_init): # Definition of attribute of name n: self.n = n_init # Def of method of name accum: def accum(self, dn): self.n += dn # Def of method of name value: def calc_value(self, v): val_invent = self.n * v return val_invent #%% Instantiation of class Inventory inventory_1 = Inventory(10) # Instance or object called inventory_1 #%% Program part where the inventory_1 object is used # Calling the method named accum: inventory_1.accum(2) # Reading the attribute named n: contents_inventory = inventory_1.n print(f'Contents of inventory: {contents_inventory}') # Calling the method named value: value_element = 100 # Value per element in inventory value_inventory = inventory_1.calc_value(value_element) print(f'Value of inventory: {value_inventory}')