ProgrammingModerateTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
from math import prod
print(prod([]), prod([2, 3, 4]), prod([1.5, 2]))
  1. A. 1 24 3
  2. B. 1 9 3.0
  3. C. 1 24 3.0
  4. D. 0 24 3.0

Correct answer: C. 1 24 3.0

The product of an empty iterable is the start value 1. 2 * 3 * 4 = 24, and multiplying the float 1.5 by 2 gives 3.0.

More Python Programming questions

Exams that ask this topic