ProgrammingModerateTCS NQT · Infosys

What is printed?

What is printed?
print(list(range(2, 20, 5)), list(range(-1, -10, -4)))
  1. A. [2, 7, 12, 17, 22] [-1, -5, -9]
  2. B. [2, 7, 12, 17] [-1, -5, -9, -13]
  3. C. [2, 7, 12] [-1, -5]
  4. D. [2, 7, 12, 17] [-1, -5, -9]

Correct answer: D. [2, 7, 12, 17] [-1, -5, -9]

range(2, 20, 5) includes starts up to but not including 20, and range(-1, -10, -4) steps down from -1 and stops before -10.

More Python Programming questions

Exams that ask this topic