Exam GPYC All QuestionsBrowse all questions from this exam
Question 8

What is the output of the following line of code typed into a Python interactive session?

>>> print(bin(0b101010 ^0b111000))

    Correct Answer: C

    The code uses the 'bin' function to convert the result of a bitwise XOR operation between two binary numbers into a binary string. The XOR operation (^) compares each bit of the two numbers and returns 1 if the bits are different, and 0 if they are the same. For 0b101010 (which is 42 in decimal) and 0b111000 (which is 56 in decimal), the result of the XOR is 0b010010, which is represented as 0b10010 in binary. Therefore, the output is 0b10010.

Discussion
AZIrvThoOption: C

C is the correct answer; when running this code, I get the same response: 0b10010.

VenudharOption: C

The option is c