Power of Two

Easy
17
81.4% Acceptance

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, and False otherwise.

Examples:

  1. Input: is_power_of_two(4)
    Output: True

    • Explanation: 4 is 2^2, hence a power of two.
  2. 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.