I'm relatively new to Python and I was wondering how I could simplify the following code any further. The code determines whether a number, n, is a power of 2 by using a for loop.
def is_power(n):
if n <= 2:
return True
for i in range(3, n):
if i * i == n:
return True
return False
Here is an oversimplification :)