fork download
  1. def pierwiastek(x, eps):
  2. a = 0
  3. b = x
  4. while abs(b - a) > eps:
  5. c= (a + b) / 2
  6. if c * c > x:
  7. b = c
  8. else :
  9. a = c
  10. return c
  11. print(pierwiastek(4,1))
Success #stdin #stdout 0.03s 9528KB
stdin
Standard input is empty
stdout
3.0