GIAC Python Coder (GPYC) — Question 30
What is the output of the following line of code typed into a Python interactive session?
>>> print(bin(0b101010 ^0b111000))
Answer options
- A. 0b10101
- B. 18
- C. 0b10010
- D. 0b101101
Correct answer: C
Explanation
The code performs a bitwise XOR operation between the binary numbers 0b101010 and 0b111000, resulting in 0b10010. This is the correct output, which is why option C is right. Options A, B, and D do not reflect the result of the XOR operation performed in the code.