ProgrammingVery hardCAT · MBA placement

What is printed?

What is printed?
print(range(0, 10, 3) == range(0, 11, 3), range(0, 10, 3)[-1], len(range(10**18)))
  1. A. False 9 1000000000000000000
  2. B. True 10 1000000000000000000
  3. C. True 9 1000000000000000000
  4. D. True 9 1000000000000000001

Correct answer: C. True 9 1000000000000000000

Two ranges compare equal when they produce the same values, and range(0, 10, 3) and range(0, 11, 3) both give 0, 3, 6 and 9. Indexing and len take constant time.

More Python Programming questions

Exams that ask this topic