ProgrammingVery hardJEE Main · CAT placement
What is printed?
What is printed?
print(1 << 100 >> 99)
try:
print(1 >> -1)
except ValueError as e:
print(e)- A. 2
- B. 2 negative shift count
- C. 1 negative shift count
- D. 2 0
Correct answer: B. 2 negative shift count
<< and >> have equal precedence and group left to right, so 1 << 100 >> 99 is 2. Shifting by a negative count raises ValueError with the message 'negative shift count'.
More Python Programming questions
- What is printed? python print(len(str(21000)), sum(map(int, str(21000))))
- What is printed? python print(1018 10 // 1018 == 10, type(1018 / 1018))
- What is printed? python print(round(1.005, 2), round(0.285, 2), round(1.45, 1))
- What is printed? python print('abcdef'[4:1:-2], 'abc'[::-2], 'abc'[-5:], 'abc'[5:] == '')
- What is printed? python import cmath print((-1) 0.5 == 1j, -1 0.5, (-1) 0.5)
- What is printed? python print((-7) % 3, 7 % -3, (-7) % -3, -7 % 3 2)