ProgrammingModerateTCS NQT · Infosys

What is printed?

What is printed?
import math
print(math.prod([2, 3, 4]), math.prod([]), math.prod([1.5, 2]), math.prod(range(1, 6)) == math.factorial(5))
  1. A. 24 0 3.0 True
  2. B. 24 1 3 True
  3. C. 24 1 3.0 True
  4. D. 24 1 3.0 False

Correct answer: C. 24 1 3.0 True

math.prod of an empty iterable is the start value 1, and it returns a float when any input is a float. The product of 1 to 5 equals 5!.

More Python Programming questions

Exams that ask this topic