def f(x): return x**2-5 def zero(f,a,b): if f(a)*f(b)>0: return None while(abs(a-b)>1e-14): m=(a+b)/2. if f(m)*f(a)>0: a=m else: b=m return m print(zero(f,0,6))