ProgrammingVery hardJEE Advanced · CAT placement
What is printed?
What is printed?
x = 255 print(x.to_bytes(2, 'little'), int.from_bytes(b'\x01\x02', 'little'), (258).to_bytes(2, 'big').hex())
- A. b'ff00' 513 0201
- B. b'\xff\x00' 258 0102
- C. b'\xff\x00' 513 0102
- D. b'\xff\x00' 513 0201
Correct answer: C. b'\xff\x00' 513 0102
Little-endian puts the low byte first, so 255 becomes b'\xff\x00'. Reading bytes 01 02 little-endian gives 0x0201, which is 513, and 258 is 0x0102 in big-endian hex.
More Python Programming questions
- 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))
- What is printed? python print(7.0 == 7, (7.0).isinteger(), (7.5).isinteger(), 1e3 == 1000)
- What is printed? python print(2 0.5 2 0.5 == 2, (2 0.5) 2, 2 0.5 2)
- What is printed? python print('%.2f' % 1.005, '%.2f' % 1.015, '%.2f' % 1.025, '%.1f' % 0.25)
- What is printed? python s = 'abc' t = s s += 'd' print(t, s, t is s, id(s) == id(t))