ProgrammingVery hardProduct-company MCQ pattern
What is printed?
What is printed?
print(bin(0b1010 << 2 >> 1 & 0xF), 0o17 + 0x1F + 0b11, 0x_ff, 1_0j)
- A. 0b100 49 255 10j
- B. 0b1010 49 255 10j
- C. 0b100 46 255 10j
- D. 0b100 49 255 1_0j
Correct answer: A. 0b100 49 255 10j
<< and >> share one precedence level and go left to right, so ((0b1010 << 2) >> 1) & 0xF gives 0b100. Underscores are allowed in literals, so 1_0j is the imaginary number 10j.
More Python Programming questions
- What is printed? python x = 0 x |= 1 << 3 x &= ~(1 << 0) x ^= 0b111 print(x, x.bitcount(), (x >> 1) & -x)
- What is printed? python print(-(-231) // 1, (231 - 1) & -(231), 231 >> 31, 232 & -232)
- What is printed? python print((1 << 3) - 1 << 2, 1 << 3 - 1 << 2, 1 + 2 << 1, 3 & 2 2)
- What is printed? python print(0 0, 0.0 0, (-8) 0, (-2) 3, -2 3)
- What is printed on the first line? python print(sorted(['10', '9', '2'], key=int)) print(sorted(['10', '9', '2'])) print(sorted(['a', 'B'…
- What is printed? python print('a' 'b' 2, ('a' 'b') 2, 'ab' 0 == '', 'x' 3 + 'y' 2)