class Value: def __init__(self, value, operands = (), operator = '') -> None: self.value = value self.operands = set(operands) self.operator = operator def __add__(self, other) -> 'Value': output = Value(self.value + other.value, (self, other), '+') return output def __mul__(self, other) -> 'Value': output = Value(self.value * other.value, (self, other), '*') return output def __repr__(self) -> str: return f'Value({self.value})' if __name__ == '__main__': x = Value(3.0) y = Value(4.0) z = x * y print(z.value) print(z.operands) print(z.operator)