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()))
  1. A. True True False 1
  2. B. True True True 1
  3. C. True True True 2
  4. 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

Exams that ask this topic