ProgrammingVery hardCAT ยท MBA placement

What is printed?

What is printed?
print(chr(0x1F600) == '๐Ÿ˜€', len('๐Ÿ˜€'), len('๐Ÿ˜€'.encode('utf-16-le')))
  1. A. True 1 4
  2. B. False 2 4
  3. C. True 2 2
  4. 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

Exams that ask this topic