# What will be the value of x in the following Python expression

## 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

## Precedence And Associativity In Python: MCQs in Python

Precedence And Associativity In Python. Multiple Choice Questions on Associativity & Precedence in Python Programming Language.

## Precedence And Associativity In Python

Which of the following expressions involves coercion when evaluated in Python ??

a) 4.7 – 1.5
b) 7.9 * 6.3
c) 1.7 % 2
d) 3.4 + 4.6

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

X = 2+9*((3*12)-8)/10

a) 30.0
b) 30.8
c) 28.4
d) 27.2

The expression 2**2**3 is evaluates as: (2**2)**3 ??

a) True
b) False

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

0x35 | 0x75

a) 115
b) 116
c) 117
d) 118

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

4+2**5//10

a) 3
b) 7
c) 77
d) 0

What is the value of the following Python expression ??

bin(0x8)

a) ‘0bx1000’
b) 8
c) 1000
d) ‘0b1000’

Precedence And Associativity In Python

Which of the following expressions results in an error ??

a) float(‘10’)
b) int(‘10’)
c) float(’10.8’)
d) int(’10.8’)

Which of the following represents the bitwise XOR operator ??

a) &
b) ^
c) |
d) !

Which of the following expressions is an example of type conversion ??

a) 4.0 + float(3)
b) 5.3 + 6.3
c) 5.0 + 3
d) 3 + 7

Which of the following expressions results in an error ??

a) int(1011)
b) int(‘1011’,23)
c) int(1011,2)
d) int(‘1011’)

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

float(4+int(2.39)%2)

a) 5.0
b) 5
c) 4.0
d) 4

Precedence And Associativity In Python

What will be the output of the following Python expression if x=15 and y=12 ??

x & y

a) b1101
b) 0b1101
c) 12
d) 1101

Which among the following list of operators has the highest precedence ??

+, -, **, %, /, <<, >>, |

a) <<, >>
b) **
c) |
d) %

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

24//6%3, 24//4//2

a) (1,3)
b) (0,3)
c) (1,0)
d) (3,1)

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

print(4.00/(2.0+2.0))

a) Error
b) 1.0
c) 1.00
d) 1

## Python Numeric Types MCQs: Python Language MCQs

Python Numeric Types MCQs. Multiple Choice Questions related to Numeric Types in Python Programming Language. This set includes 20 Multiple Choice Questions with Answers on Expressions and Numeric Types in Python Language.

## Python Numeric Types MCQs

What is the result of cmp(3, 1) ??

a) 1
b) 0
c) True
d) False

What does ~~~~~~5 evaluate to ??

a) +5
b) -11
c) +11
d) -5

What does ~4 evaluate to ??

a) -5
b) -4
c) -3
d) +3

Which of the following is not a complex number ??

a) k = 2 + 3j
b) k = complex(2, 3)
c) k = 2 + 3l
d) k = 2 + 3J

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

x = int(43.55+2/2)

a) 43
b) 44
c) 22
d) 23

Python Numeric Types MCQs

Which of the following operators has its associativity from right to left in Python ??

a) +
b) //
c) %
d) **

What does 3 ^ 4 evaluate to ??

a) 81
b) 12
c) 0.75
d) 7

What is the result of round(0.5) – round(-0.5) ??

a) 1.0
b) 2.0
c) 0.0
d) Value depends on Python version

Which of the following is incorrect ??

a) float(‘inf’)
b) float(‘nan’)
c) float(’56’+’78’)
d) float(’12+34′)

Which of the following is incorrect ??

a) x = 0b101
b) x = 0x4f5
c) x = 19023
d) x = 03964

Python Numeric Types MCQs

What is the type of inf in Python ??

a) Boolean
b) Integer
c) Float
d) Complex

What is the output of print 0.1 + 0.2 == 0.3 ??

a) True
b) False
c) Machine dependent
d) Error

What is the value of the following expression ??

float(22//3+3/3)

a) 8
b) 8.0
c) 8.3
d) 8.33

What is the value of the following expression ??

8/4/2, 8/(4/2)

a) (1.0, 4.0)
b) (1.0, 1.0)
c) (4.0. 1.0)
d) (4.0, 4.0)

What are the values of the following Python expressions ??

2**(3**2)
(2**3)**2
2**3**2

a) 64, 512, 64
b) 64, 64, 64
c) 512, 512, 512
d) 512, 64, 512

Python Numeric Types MCQs

Which of the following is the truncation division operator ??

a) /
b) %
c) //
d) |

What is the value of the following expression ??

2+4.00, 2**4.0

a) (6.0, 16.0)
b) (6.00, 16.00)
c) (6, 16)
d) (6.00, 16.0)

Evaluate the expression given below if A = 16 and B = 15 ??

A % B // A

a) 0.0
b) 0
c) 1.0
d) 1

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

4 + 3 % 5

a) 4
b) 7
c) 2
d) 0

The value of the expressions 4/(3*(2-1)) and 4/3*(2-1) is the same ??

a) True
b) False

error: Content is protected !!