ProgrammingHardGATE CS · Product-company placement

What is printed?

What is printed?
for kw in [{}, {"strict": True}]:
    try:
        print(list(zip("ab", [1, 2, 3], **kw)), end=" ")
    except ValueError:
        print("VE", end=" ")
print(list(enumerate("xy", start=5)))
  1. A. [('a', 1), ('b', 2)] VE [(5, 'x'), (6, 'y')]
  2. B. [('a', 1), ('b', 2)] [('a', 1), ('b', 2)] [(5, 'x'), (6, 'y')]
  3. C. VE VE [(5, 'x'), (6, 'y')]
  4. D. [('a', 1), ('b', 2)] VE [(0, 'x'), (1, 'y')]

Correct answer: A. [('a', 1), ('b', 2)] VE [(5, 'x'), (6, 'y')]

zip normally stops at the shortest input; with strict=True (Python 3.10+) unequal lengths raise ValueError. enumerate's start only changes the counter values.

More Python Programming questions

Exams that ask this topic