title: python3 function to check if parameter is a power of 2 with a while loop and without using math function
body: <p>Learning about functions in python3.  A course question was to define a function using a while loop (and without using the math function) that determines if a parameter is a power of 2.  If it is, return True.  If it is not, return False.  Here is the starting code:</p>
  <pre><code>def is_power_of_two(n):
    # Check if the number can be divided by two without a remainder
    while n % 2 == 0:
      n = n / 2
    # If after dividing by two the number is 1, it's a power of two
    if n == 1:
      return True
    return False
    
  
  print(is_power_of_two(0)) # Should be False
  print(is_power_of_two(1)) # Should be True
  print(is_power_of_two(8)) # Should be True
  print(is_power_of_two(9)) # Should be False
  </code></pre>
  <p>I can find examples with loops (other than while) and when using the math function, but am at a loss without
  either of those options.</p>