ProgrammingHardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
from functools import reduce
print(reduce(lambda a, b: a * b, range(1, 21), 1), reduce(lambda a, b: a + b, [], 0))
  1. A. 2432902008176640001 0
  2. B. 1216451004088320000 0
  3. C. 2432902008176640000 0
  4. D. 2432902008176640000 None

Correct answer: C. 2432902008176640000 0

reduce with initial value 1 multiplies 1 through 20, which gives 20! = 2432902008176640000. Reducing an empty iterable returns the initial value 0.

More Python Programming questions

Exams that ask this topic