title: Square root calculation using bisection
body: <p>I have the following code which should find the square root using bisection, but for some reason it won't. When I want to find the square root of 9 I get 4.5. </p>
  
  <pre><code>y = float(input('Enter the number that you want to find the square root of: '))
  z = y
  x = 0
  ans = 0
  
  while abs(ans**2 - abs(y)) &gt; 0.0001 and ans &lt;= x:
      ans = (x + y) / 2.0
  
      if ans**2 &lt; z:
          x = ans
      else:
          y = ans
  
  
  print 'The square root of', z, 'is', ans
  </code></pre>