ProgrammingHardTCS CodeVita · Infosys HackWithInfy · Product Company SDE

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

  1. A. [12, 7, 21, 56] 4
  2. B. [3, 49, 21] 3
  3. C. [32, 3, 49, 21] 4
  4. D. [7, 8, 10, 15] 4

Correct answer: A. [12, 7, 21, 56] 4

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

More Python Programming questions

Exams that ask this topic