title: While loop from How to think like computer scientist
body: <p>I am complete newbie and just have started with Think Python book.
  On the chapter about Iteration the author brings examples about while loop as following:</p>
  
  <pre><code>def countdown(n):
      while n &gt; 0:
          print n
          n = n-1
      print "Blastoff!"
  </code></pre>
  
  <p>This is quite simple to understand , print n and when n=n-1 up to the point till n>0 holds true.</p>
  
  <p>but the next example is a little bit different and I do not understand this:</p>
  
  <pre><code>def sequence(n):
      while n != 1:
          print n,
          if n % 2 == 0:        # n is even
              n = n / 2
          else:                 # n is odd
              n = n * 3 + 1
  </code></pre>
  
  <p>n!=1 will become true if and only if n=0 or n=1, in this example it will not be possible that n=0 as a result of subsequent calculation and we assume that n=0 as initial input.
  So let say n=3
  the calculation will be as follows: 3,10,5,16,8,4,2,1.</p>
  
  <p>Analyzing both example I saw controversy:</p>
  
  <p>in example 1.The loop is kept up to the point  the condition n>0 is true, as soon as n>0 is false the loop is broken.
  In example 2. The loop is kept up to the point the condition n!=1 is false, as soon as n!=1 becomes true the loop is broken.</p>
  
  <p>Having observed these 2 cases , I see controversy how while loop is working in the first example while loop is executed up to the point the condition is true and in the second example it is executed up to the point the condition is false.
  Please advise how to understand it , if we do not mention that the condition should be true or false, why the programm executes loop one time in true bool, and the second time in false bool?</p>