ProgrammingModerateTCS NQT · Wipro pattern
What is printed?
What is printed?
print('abc'.encode() == b'abc', b'abc'.decode() == 'abc', 'é'.encode('utf-8') == b'\xc3\xa9', len(b'\xc3\xa9'.decode()))- A. True True False 1
- B. True True True 1
- C. True True True 2
- D. True False True 1
Correct answer: B. True True True 1
ASCII text encodes to the same bytes, and é in UTF-8 is the two bytes c3 a9. Decoding those bytes gives one character, é.
More Python Programming questions
- What is printed? python print('%.3s' % 'abcdef' + '|' + '%-4d|' % 7 + '%04.1f' % 2.25)
- What is printed? python x = 0xFF print(x >> 4, x & 0xF0, x ^ 0x0F, ~x & 0xFF)
- What is printed? python print(int.frombytes((65).tobytes(1, 'big') 3, 'big'), 65 65 65, bytes([65] 3).decode())
- What is printed? python print(max(['10', '9'], key=len), max(['10', '9']), max([10, 9], key=str))
- What is printed? python print(10 == 10.0 and 'a' == 'a', 1 < 2 or 1 / 0)
- What is printed? python print(sum(x for x in range(1, 101) if x % 3 == 0 or x % 5 == 0))