Practice these problems to strengthen your understanding of bitwise operators in Python. These are the type of coding challenges that can appear in QA Automation Engineer interviews.
Write a program to check if a number is odd or even using bitwise operators (without using the modulus operator).
Example:
7
→ Output: Odd10
→ Output: EvenWrite a function that checks if a given number is a power of 2.
Example:
16
→ Output: True18
→ Output: FalseGiven a list where every element appears twice except one element, find that unique element using bitwise operators.
Example:
[2, 3, 5, 3, 2]
5
Swap two numbers without using a temporary variable. Use bitwise XOR operator.
Example:
a=5, b=7
a=7, b=5