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')
- A. True 1 2 3 True
- B. False 1 1 2 True
- C. False 1 2 3 False
- 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
- What is printed? python print(len('héllo'.encode('utf-8')), len('héllo'.encode('utf-16')), len('héllo'))
- What is printed? python print('abc' < 'abd', 'Z' < 'a', '10' < '9', [10] < [9], (1, 'b') < (1, 'a'))
- What is printed on the second line? python print(''.join(sorted('banana'))) print(sorted('Banana', key=str.lower)) print(sorted(['b10'…
- What is printed? python print(min([3, 1.0, True]), max([1, True, 1.0]), max([True, 1.0]), min([1.0, True]))
- What is printed? python print(list(range(10, 0, -3)), range(0, 10, 3)[-1], len(range(5, 1)), range(3) == range(0, 3, 1), range(0, 6, 2) ==…
- What is printed? python print(sum(range(106)) == 106 (106 - 1) // 2, 20.5 20.5 == 2.0, 20.5 20.5)