command pattern def undo(self)self receiver multiply(self valueclass calculationinvoker(object)def __init__(self)self commands [self undo_stack [def add_new_command(selfcommand)self commands append(commanddef run(self)for command in self commandscommand execute(self undo_stack append(commanddef undo(self)undo_command self undo_stack pop(undo_command undo(class accumulator(object)def __init__(selfvalue)self _value value def add(selfvalue)self _value +value def subtract(selfvalue)self _value -value def multiply(selfvalue)self _value *value def divide(selfvalue)self _value /value def __str__(self)return "current value{}format(self _value