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