ProgrammingModerateTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
print(list(map(sum, zip([1, 2], [3, 4]))), list(zip(*[[1, 2], [3, 4]])))
  1. A. [3, 4] [(1, 3), (2, 4)]
  2. B. [4, 6] [[1, 4], [2, 3]]
  3. C. [4, 6] [(1, 3), (2, 4)]
  4. D. [4, 6] [(1, 2), (3, 4)]

Correct answer: C. [4, 6] [(1, 3), (2, 4)]

zip pairs the lists element-wise, so the sums are 1 + 3 and 2 + 4. zip(*) of the two rows transposes them into column tuples.

More Python Programming questions

Exams that ask this topic