ProgrammingVery hardProduct-company MCQ pattern
What is printed?
What is printed?
print(list('hi'.encode('utf-16-le')), len('hi'.encode('utf-32')))- A. [104, 0, 105, 0] 8
- B. [104, 105] 12
- C. [0, 104, 0, 105] 12
- D. [104, 0, 105, 0] 12
Correct answer: D. [104, 0, 105, 0] 12
UTF-16 little-endian stores each ASCII letter as its byte followed by a zero byte. UTF-32 adds a four-byte byte-order mark and four bytes per character, so 4 + 2 * 4 = 12.
More Python Programming questions
- What is printed? python print(bytes([104, 105]).decode(), bytes(b'ab').hex(), bytes([10, 255]).hex())
- What is printed? python print(f'{0.1:.1f}', f'{0.25:.1f}', f'{0.35:.1f}', f'{0.45:.1f}')
- What is printed? python print(5 // 2 2, 5 >> 2, 5 / 2 2)
- What is printed? python print(1 + 2 3 2 // 4 % 5, (1 + 2) 3 2 // 4 % 5)
- What is printed? python print(1 == 1.0 and '1' != 1, [1, 2] == [1.0, 2.0], (1, 'a') == (1.0, 'a'))
- What is printed? python print(set([1, 2]) == {1.0, 2.0}, {1: 'x'}.get(1.0), {'1': 2}.get(1))