ProgrammingModerateTCS NQT · Wipro pattern
What is printed?
What is printed?
s = 'héllo'
print(s[1], s.encode('latin-1')[1], len(s.encode('utf-16-le')), s.isascii())- A. e 233 10 False
- B. é 233 5 False
- C. é 233 10 False
- D. é 233 10 True
Correct answer: C. é 233 10 False
The second character is é, which is code point 233 and fits in one latin-1 byte. The UTF-16 encoding of five characters is 10 bytes, and the string is not ASCII.
More Python Programming questions
- What is printed? python from decimal import Decimal, getcontext getcontext().prec = 4 print(Decimal(1) / Decimal(3), Decimal('1.10') ==…
- What is printed? python print(sorted([(2, 'b'), (1, 'z'), (2, 'a')], reverse=True))
- What is printed? python print(7 / 2 // 1, 7 // 2 / 1, -7 / 2 // 1, 7 % 2.5)
- What is printed? python print('abc'.find(''), 'abc'.count(''), ''.split(), ''.split(','))
- What is printed? python from fractions import Fraction print(Fraction(1, 3) == 1/3, Fraction(1, 3) == Fraction('0.3333333333333333')…
- What is printed? python print('Hello, World'.swapcase(), 'hello world'.title(), "it's here".capitalize(), 'ABC'.isupper())