I am trying to write a basic algorithm to evaluate a fourth order polynomial using Python. The code is below, and I am not sure what I am doing wrong. I came up with this code and I am not sure if it is enough to do the trick:
x = int(raw_input(":"))
def eval_poly(x):
if abs(x) > 0:
return 35x**4-17x**3+5x**2+41x-29
print eval_poly(x)
The error that I get says that 35x**4
is an invalid syntax and the polynomial that I am trying to evaluate is as follows:
35x^4 - 17x^3 + 5x^2 + 41x -29