ProgrammingModerateTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
print([i * j for i, j in zip(range(3), range(3, 0, -1))])
  1. A. [0, 2, 2]
  2. B. [3, 2, 1]
  3. C. [0, 1, 2]
  4. D. [0, 2, 4]

Correct answer: A. [0, 2, 2]

The pairs from zip are (0, 3), (1, 2) and (2, 1), so the products are 0, 2 and 2.

More Python Programming questions

Exams that ask this topic