Мой код это:
Код: Выделить всё
def formula(address):
address0 = 30
logic = 3 * x
# Define the symbol and the summation range
x = symbols('x')
expr = Piecewise(
(x + logic, logic == address0), # When x equals certain_integer, only add logic
((x + logic) - (x + logic), logic!=address0) # For all other values of x, apply full logic (x + logic - x + logic)
)
#If -x + logic only do it to the ones that aren't address0
total = summation(expr(x, 0, 089237316195423570985008687907836))
total2 = total - address0
print(f'{total}\n{total2}')
return total2
Подробнее здесь: https://stackoverflow.com/questions/790 ... t-to-sympy