Hang on...
Power of Two
In this lab, you will develop a function named is_power_of_two()
in Python. This function takes a single integer parameter and determines if it is a power of two. The function should return a boolean value - True
if the number is a power of two, and False
otherwise.
Function Requirements:
- The function should be named
is_power_of_two
. - It should take one integer parameter.
- The function should return
True
if the input is a power of two, andFalse
otherwise.
Examples:
-
Input:
is_power_of_two(4)
Output:True
- Explanation: 4 is 2^2, hence a power of two.
-
Input:
is_power_of_two(6)
Output:False
- Explanation: 6 cannot be expressed as 2 raised to an integer.
Your task is to implement this function and ensure it meets the specified behavior in these examples and other test cases.
Adding your container request
Getting your dedicated container
Connecting to your container
Setting up your editor
Finalizing your playground
TerminalEditorBrowser