def newton_method(f, f_p, prec=0.01):
    x = 7
x_p = 1
tmp = 0
while True:
    tmp = x
x = x_p - f(x_p) / float(f_p(x_p))
print((x, x_p, _tmp))
if abs(x - x_p) < prec:
    break
x_p = tmp
Newton's method: order of statements in loop