ProgrammingHardTCS CodeVita · Infosys HackWithInfy · Product Company SDE

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

  1. A. [40, 20, 27, 27] 4
  2. B. [13, 9, 12, 12] 4
  3. C. [15, 36, 27, 15] 5
  4. D. [32, 15, 27] 3

Correct answer: A. [40, 20, 27, 27] 4

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

More Python Programming questions

Exams that ask this topic