QuestionQ16

Python Basics

What is the output of this line of code entered in a Python interactive session?

>>> print(bin(0b101010 ^ 0b111000))  
  • A 0b10101
  • B 18
  • C 0b10010
  • D 0b101101
Explanation

The ^ operator performs bitwise XOR, producing 0b10010 from the two binary operands. bin() returns that value as a binary string with the 0b prefix, and print() displays it.

Community Discussion

No comments yet. Be the first to start the discussion!