ProgrammingVery hardCAT ยท MBA placement
What is printed?
What is printed?
print(chr(0x1F600) == '๐', len('๐'), len('๐'.encode('utf-16-le')))- A. True 1 4
- B. False 2 4
- C. True 2 2
- D. True 1 2
Correct answer: A. True 1 4
Python strings count code points, so an emoji outside the BMP is one character. In UTF-16 it needs a surrogate pair of two 16-bit units, which is four bytes.
More Python Programming questions
- What is printed? python print(10400 > float('inf'), float('inf') > 10400, float(10308) == 10308)
- What is printed? python print('ab' in ['a', 'ab'], 'ab' in 'a,ab'.split(','), 'a' in 'abc' and 'ac' in 'abc')
- What is printed? python print(f'{-5:x}', f'{-5 & 0xF:x}', hex(-255), format(255, '#010b'))
- What is printed? python students = [('Ravi', 88), ('Asha', 92), ('Bala', 88), ('Chitra', 92)] print([n for n, s in sorted(studentsโฆ
- What is printed? python print('Hello'[1:3] + 'Hello'[-1], len('Hello'[10:]), 'Hello'[::2])
- What is printed? python print(10 / 3 3 == 10, 10 // 3 3 == 10, 10 % 3)