ProgrammingModerateTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
print(list(range(10, 0, -4)), [sum(r) for r in [(1, 2), (3,)]])
  1. A. [10, 6, 2] [2, 3]
  2. B. [10, 6, 2] [3, 3]
  3. C. [10, 6, 2, 0] [3, 3]
  4. D. [10, 6] [3, 3]

Correct answer: B. [10, 6, 2] [3, 3]

range(10, 0, -4) gives 10, 6, 2 and stops before 0. Each row is summed, giving 3 and 3.

More Python Programming questions

Exams that ask this topic