Ad

the test inputs are wrong, because you can check only using the modulus operation, if it was created correctly 30 shouldn't be assign as true, but it only test results from 2 exponentiation

Code
Diff
  • def power_of_two( n ):
        if n % 2 == 0: return True
        else: return False
    • def power_of_two( n ):
    • return n & ( n - 1 ) == 0
    • if n % 2 == 0: return True
    • else: return False