ProgrammingModerateTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
print(list(range(-3, 3)), list(zip(range(3), 'ab')))
  1. A. [-3, -2, -1, 0, 1, 2] [(0, 'a'), (1, 'b'), (2, None)]
  2. B. [-3, -2, -1, 0, 1, 2] [(0, 'a'), (1, 'b')]
  3. C. [-3, -2, -1, 0, 1, 2, 3] [(0, 'a'), (1, 'b')]
  4. D. [-2, -1, 0, 1, 2] [(0, 'a'), (1, 'b')]

Correct answer: B. [-3, -2, -1, 0, 1, 2] [(0, 'a'), (1, 'b')]

range(-3, 3) stops before 3. zip stops at the shorter input, which is the two-letter string.

More Python Programming questions

Exams that ask this topic