ProgrammingModerateProduct-company MCQ pattern

What is printed?

What is printed?
print([10, 20, 30][True], (5).bit_length(), (True).bit_length(), (-1).bit_length())
  1. A. 10 3 1 1
  2. B. 20 3 2 1
  3. C. 20 3 1 1
  4. D. 20 3 0 1

Correct answer: C. 20 3 1 1

True is 1 when used as an index, so it picks 20. bit_length uses the magnitude, so 5 needs 3 bits and both True and -1 need 1 bit.

More Python Programming questions

Exams that ask this topic