title: pyschools square root approximation
body: <p>I am new to Python and stackoverflow. I have been trying to solve Pyschools 'while loop' example for square root approximation (Topic 5: Question 9). However I am unable to get the desired output. I am not sure if this issue is related to the loop or the formula. Here is the question:</p>
  
  <blockquote>
    <p>Create a function that takes in a positive number and return 2
    integers such that the number is between the squares of the 2
    integers. It returns the same integer twice if the number is a square
    of an integer.</p>
    
    <hr>
  </blockquote>
  
  <p>Examples:</p>
  
  <pre><code>sqApprox(2)
  (1, 2)
  sqApprox(4)
  (2, 2)
  sqApprox(5.1)
  (2, 3)
  </code></pre>
  
  <p>Here is my code:</p>
  
  <hr>
  
  <pre><code>def sqApprox(num):
      i = 0
      minsq = 1                           # set lower bound
      maxsq = minsq                       # set upper bound
      while i*i&lt;=num:                     # set 'while' termination condition
          if i*i&lt;=num and i &gt;=minsq:  # complete inequality condition  
              minsq = i
          if i*i&lt;=num and i &lt;=maxsq:  # complete inequality condition
              maxsq = i
          i=i+1                       # update i so that 'while' will terminate
      return (minsq, maxsq)
  </code></pre>
  
  <hr>
  
  <p>If I create this function <code>sqApprox(4)</code> and call it on IDE, I get output <code>(2, 0)</code>.</p>
  
  <p>Could someone please let me know what I am doing wrong? Thanks in advance.</p>