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É')
- A. 7 7 True
- B. 7 11 False
- C. 7 11 True
- 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
- What is printed? python print(int('10', 2), int('0o17', 0), int('17', 8), int('0xff', 16))
- What is printed? python x = 0xDEAD print(x >> 8 & 0xFF, (x >> 8) & 0xF, hex(x & -x))
- What is printed? python print(sorted([-3, 2, -1, 4], key=lambda v: (abs(v) % 3, v)))
- What is printed? python print(f'{1234.5:,.2f}', f'{0.000123:.2e}', f'{-0.0:+.1f}', f'{0x123456:x}')
- What is printed? python print(int('٠٠٢٩') + 1, '٢٩'.isdigit())
- What is printed? python s = 'abc' print(s 0 == '', s[::-1][::-1] == s, s[1:-1] 2, s[-3:-1])