ProgrammingVery hardProduct-company MCQ pattern

What is printed?

What is printed?
s1 = '\u00e9'
s2 = 'e\u0301'
print(s1 == s2, len(s1), len(s2), len(s2.encode()), s2 == 'e\u0301')
  1. A. True 1 2 3 True
  2. B. False 1 1 2 True
  3. C. False 1 2 3 False
  4. D. False 1 2 3 True

Correct answer: D. False 1 2 3 True

Python compares code points without normalising, so the precomposed e-acute and the letter e plus a combining accent are different strings. The second form is two code points and three bytes in UTF-8.

More Python Programming questions

Exams that ask this topic