ProgrammingVery hardCAT · MBA placement
What is printed?
What is printed?
print(len('é'.encode('utf-8').decode('latin-1')), 'é'.encode('utf-8').decode('latin-1'))- A. 2 é
- B. 1 é
- C. 2 é
- D. 3 é
Correct answer: A. 2 é
é is two bytes in UTF-8, and decoding those bytes as Latin-1 gives two separate characters, Ã and ©. So the string has two characters.
More Python Programming questions
- What is printed? python print(sum(1 for c in 'Mississippi' if c in 'aeiouAEIOU'), 'Mississippi'.lower().count('s')…
- What is printed? python print([] == [] or 1 / 0, [] and 1 / 0, 0 or 1 and 2)
- What is printed? python print(3 % 2 == 1 and 4 % 2 == 0, 3 // 2 == 1 or 1 / 0)
- What is printed? python print(f'{"":>3}|', f'{"x":^3}|', f'{None!s:>6}|')
- What is printed? python from functools import lrucache @lrucache(maxsize=None) def t(n): if n == 0: return 0 if n < 3: return 1 return t(n…
- What is printed? python from collections import deque def countpaths(g): R, C = len(g), len(g[0]) dist = [[-1] C for in range(R)] ways =…