ProgrammingHardProduct-company MCQ pattern

What is printed?

What is printed?
print(sum([True, True, False]), sum([1.5, True]), True * 3 + 0.5, sum([1, 2], 10))
  1. A. 2 2.5 3.5 13
  2. B. 3 2.5 3.5 13
  3. C. 2 2.5 3.5 12
  4. D. 2 2.5 3.0 13

Correct answer: A. 2 2.5 3.5 13

bool is a subclass of int, so True counts as 1 in sum and arithmetic. The start value 10 is added to 1 + 2, giving 13.

More Python Programming questions

Exams that ask this topic