ProgrammingModerateTCS NQT · Wipro pattern

What is printed?

What is printed?
s = 'Ünïcödé'
print(len(s), len(s.encode()), s.upper() == 'ÜNÏCÖDÉ')
  1. A. 7 7 True
  2. B. 7 11 False
  3. C. 7 11 True
  4. D. 8 11 True

Correct answer: C. 7 11 True

The string has seven code points, but Ü, ï, ö and é take two bytes each in UTF-8, which gives 11 bytes in total. upper() maps each letter to its capital form, so the comparison is True.

More Python Programming questions

Exams that ask this topic