ProgrammingHardTCS CodeVita · Infosys HackWithInfy · Product Company SDE

What does the following Python 3 code print? a, b = [3,1,8,5,4,7], [7,4,2,5] print(list(map(lambda p: p[0] * p[1], zip(a, b))), len(list(zip(a, b))))

  1. A. 66 6
  2. B. [12, 2, 40] 3
  3. C. [21, 4, 16, 25] 4
  4. D. [10, 5, 10, 10] 4

Correct answer: C. [21, 4, 16, 25] 4

zip stops at the shorter input, so only min(len(a), len(b)) pairs are produced. Output: [21, 4, 16, 25] 4.

More Python Programming questions

Exams that ask this topic