ProgrammingHardProduct-company MCQ pattern

What is printed?

What is printed?
print(list(range(-5, 5, 4)), list(range(5, -5, -4)), range(-1, -4, -1)[0])
  1. A. [-5, -1, 3] [5, 1, -3] -2
  2. B. [-5, -1, 3] [5, 2, -3] -1
  3. C. [-5, -1, 3] [5, 1, -3] -1
  4. D. [-5, -1, 3] [5, 1, -3] 0

Correct answer: C. [-5, -1, 3] [5, 1, -3] -1

range(-5, 5, 4) steps from -5 up to but not including 5, giving -5, -1, 3. A negative step counts down from its start, so range(-1, -4, -1) begins at -1.

More Python Programming questions

Exams that ask this topic