103
57.3k
Chapter:

Bitwise Operator Solved MCQs

in Problem Solving and Python Programming

These multiple-choice questions (MCQs) are designed to enhance your knowledge and understanding in the following areas: Computer Science Engineering (CSE) , Information Technology Engineering (IT) , Electrical Engineering , Civil Engineering , Mechanical Engineering .

Chapters

Chapter: Bitwise Operator
1.

What will be the output of the following Python expression? int(1011)?

A. 1011
B. 11
C. 13
D. 1101
Answer» A. 1011
Explanation: the result of the expression shown will be 1011. this is because we have not specified the base in this expression.
2.

Which of the following expressions results in an error?

A. int(1011)
B. int(‘1011’,23)
C. int(1011,2)
D. int(‘1011’)
Answer» C. int(1011,2)
Explanation: the expression int(1011,2) results in an error. had we written this expression as int(‘1011’,2), then there would not be an error.
3.

Which of the following represents the bitwise XOR operator?

A. &
B. ^
D. !
Answer» B. ^
Explanation: the ^ operator represent bitwise xor operation. &: bitwise and,
4.

What is the value of the following Python expression? bin(0x8)

A. ‘0bx1000’
B. 8
C. 1000
D. ‘0b1000’
Answer» D. ‘0b1000’
Explanation: the prefix 0x specifies that the value is hexadecimal in nature. when we convert this hexadecimal value to binary form, we get the result as: ‘0b1000’.
5.

What will be the output of the following Python expression? 0x35 | 0x75

A. 115
B. 116
C. 117
D. 118
Answer» C. 117
Explanation: the binary value of 0x35 is 110101 and that of 0x75 is 1110101. on or- ing these two values we get the output as: 1110101, which is equal to 117. hence the result of the above expression is 117.
6.

It is not possible for the two’s complement value to be equal to the original value in any case.

A. true
B. false
Answer» B. false
Explanation: in most cases the value of two’s
7.

Bitwise                    gives 1 if either of the bits is 1 and 0 when both of the bits are 1.

A. or
B. and
C. xor
D. not
Answer» C. xor
Explanation: bitwise xor gives 1 if either of the bits is 1 and 0 when both of the bits are 1.
8.

What will be the output of the following
Python expression?
4^12

A. 2
B. 4
C. 8
D. 12
Answer» C. 8
Explanation: ^ is the xor operator. the binary form of 4 is 0100 and that of 12 is 1100. therefore, 0100^1100 is 1000, which is equal to 8.

Done Studing? Take A Test.

Great job completing your study session! Now it's time to put your knowledge to the test. Challenge yourself, see how much you've learned, and identify areas for improvement. Don’t worry, this is all part of the journey to mastery. Ready for the next step? Take a quiz to solidify what you've just studied.