Python Bitwise Operators: Bitwise In Python Language

Python Bitwise Operators. Multiple Choice Questions on Python Bitwise Operators And Compliments in Python Programming Language.

Python Bitwise Operators MCQs

 

What will be the value of the following Python expression ??

bin(10-2)+bin(12^4)

a) 0b10000
b) 0b10001000
c) 0b1000b1000
d) 0b10000b1000

 

What will be the output of the following Python expression ??

~100?

a) 101
b) -101
c) 100
d) -100

 

What is the two’s complement of -44 ??

a) 1011011
b) 11010100
c) 11101011
d) 10110011

 

What will be the output of the following Python code if a=10 and b =20 ??

a=10
b=20
a=a^b
b=a^b
a=a^b
print(a,b)

a) 10 20
b) 10 10
c) 20 10
d) 20 20

 

Which of the following expressions can be used to multiply a given number ‘a’ by 4 ??

a) a<<2
b) a<<4
c) a>>2
d) a>>4

Python MCQs

 

To find the decimal value of 1111, that is 15, we can use the function ??

a) int(1111,10)
b) int(‘1111’,10)
c) int(1111,2)
d) int(‘1111’,2)

 

What will be the output of the following Python expression ??

int(1011)?

a) 1011
b) 11
c) 13
d) 1101

 

What will be the value of x in the following Python expression, if the result of that expression is 2 ??

x>>2

a) 8
b) 4
c) 2
d) 1

 

What will be the output of the following Python expression ??

bin(29)

a) ‘0b10111’
b) ‘0b11101’
c) ‘0b11111’
d) ‘0b11011’

 

What will be the output of the following Python code snippet if x=1 ??

x<<2

a) 8
b) 1
c) 2
d) 4

Python Bitwise Operators MCQs

 

Any odd number on being AND-ed with ________ always gives 1 ??

Hint: Any even number on being AND-ed with this value always gives 0 ??

a) 10
b) 2
c) 1
d) 0

 

What will be the output of the following Python expression ??

4^12

a) 2
b) 4
c) 8
d) 12

 

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

 

The one’s complement of 110010101 is ??

a) 001101010
b) 110010101
c) 001101011
d) 110010100

 

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

a) True
b) False

 

More MCQ Posts

Leave a Comment

Your email address will not be published. Required fields are marked *

error: Content is protected !!