ProgrammingVery hardJEE Advanced · CAT placement
What is printed?
What is printed?
print(1 << 31 >> 31, (1 << 31) >> 31 == 1, -1 >> 31, -2**31 >> 31)
- A. 1 True -1 -1
- B. 2 True -1 -1
- C. 1 False -1 -1
- D. 1 True 0 -1
Correct answer: A. 1 True -1 -1
Shifts group left to right, so 1 << 31 >> 31 is 1. Right shifting a negative number keeps the sign and rounds toward negative infinity, so -1 >> 31 and -2**31 >> 31 are both -1.
More Python Programming questions
- What is printed? python print('1' + '2' 3, '1' 2 + '2', len('ab' 0 + 'c' 3), 'x' 2 == 'xx')
- What is printed? python from math import gcd, lcm print(gcd(-12, 18), gcd(0, 0), lcm(4, 6), gcd(2100, 650) == 250)
- What is printed? python print(0.5 == 1/2, 0.1 + 0.4 == 0.5, 0.25 + 0.25 == 0.5, 0.7 + 0.1 == 0.8)
- What is printed? python x = 255 print(x.tobytes(2, 'little'), int.frombytes(b'x01x02', 'little'), (258).tobytes(2, 'big').hex())
- What is printed? python print(len(str(10100 - 1)), str(105)[:3], int('9' 50) % 9)
- What is printed? python print(round(1234.5678, -2), round(1234.5678, 2), round(-0.0001, 3), round(5.5), round(6.5))