ProgrammingHardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
print(list(zip('ab', 'cd', 'ef'))[1], dict(zip('ab', [1])))
  1. A. ('b', 'd', 'f') {'a': 1, 'b': 1}
  2. B. ('b', 'd', 'f') {'a': 1, 'b': 0}
  3. C. ('b', 'd', 'f') {'a': 1}
  4. D. ('b', 'd') {'a': 1, 'b': None}

Correct answer: C. ('b', 'd', 'f') {'a': 1}

All three strings have length 2, so the second tuple holds b, d and f. dict of zip stops at the shorter input, so only 'a' gets the value 1.

More Python Programming questions

Exams that ask this topic