I'm trying to find the number of bisections Python takes to produce the root of a function. For example, if I have the code:
import math
a=1
b=2
def f(x):
    return x**3+x-7
while b-a>0.001:
    c=(a+b)/2
    if f(a)*f(c)>0:
         a=c
    else:
         b=c
print(c)
This code will simply produce the desired answer. I would like to know how many times Python performed the bisection method and what were the values each time.
 
     
    