ProgrammingModerateTCS NQT · Wipro pattern

What is printed?

What is printed?
s = 'héllo'
print(s[1], s.encode('latin-1')[1], len(s.encode('utf-16-le')), s.isascii())
  1. A. e 233 10 False
  2. B. é 233 5 False
  3. C. é 233 10 False
  4. D. é 233 10 True

Correct answer: C. é 233 10 False

The second character is é, which is code point 233 and fits in one latin-1 byte. The UTF-16 encoding of five characters is 10 bytes, and the string is not ASCII.

More Python Programming questions

Exams that ask this topic