ProgrammingHardTCS NQT · Accenture

What is printed?

What is printed?
print(sum([1, 2], 0.5))
  1. A. 3
  2. B. 3.0
  3. C. 2.5
  4. D. 3.5

Correct answer: D. 3.5

The start value 0.5 is a float, so the running total becomes a float, and 0.5 + 1 + 2 is 3.5.

More Python Programming questions

Exams that ask this topic