count = 0 x = 10 while x > 0: x = x // 2 # truncating division count += 1 print "The approximate log2 is", count