Precedence And Associativity In Python: MCQs in Python

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

 

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’

 

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

 

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)

 

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

 

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

 

 

Leave a Comment

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

error: Content is protected !!