ProgrammingModerateCognizant GenC · Python

What is printed?

What is printed?
print(list(zip('abc', range(5))), dict(zip('ab', [1, 2, 3])))
  1. A. [('a', 0), ('b', 1), ('c', 2)] {'a': 1, 'b': 2}
  2. B. [('a', 0), ('b', 1), ('c', 2), (None, 3), (None, 4)] {'a': 1, 'b': 2}
  3. C. [('a', 0), ('b', 1), ('c', 2)] {'a': 1, 'b': 2, None: 3}
  4. D. [('a', 0), ('b', 1)] {'a': 1, 'b': 2}

Correct answer: A. [('a', 0), ('b', 1), ('c', 2)] {'a': 1, 'b': 2}

zip stops at the shortest iterable, so each result has only as many pairs as the shorter input.

More Python Programming questions

Exams that ask this topic