ProgrammingHardProduct-company MCQ pattern

What is printed?

What is printed?
print(len(bytes(3)), bytes([65, 66]) == b'AB', bytearray(b'ab') == b'ab', type(b'a'[0]).__name__)
  1. A. 3 True True bytes
  2. B. 2 True True int
  3. C. 3 False True int
  4. D. 3 True True int

Correct answer: D. 3 True True int

bytes(3) is three zero bytes. Indexing a bytes object returns an int, not a one-byte bytes object, and bytearray compares equal to bytes with the same content.

More Python Programming questions

Exams that ask this topic