ProgrammingHardTCS NQT · Wipro pattern

What is printed?

What is printed?
print(sum(range(10 ** 6)) % 1000, sum(range(1, 11)) // 5)
  1. A. 0 10
  2. B. 500 11
  3. C. 0 11
  4. D. 5 11

Correct answer: C. 0 11

The sum of 0 to 999999 is 499999500000, which ends in 000 and so is 0 mod 1000. The sum of 1 to 10 is 55, and 55 // 5 is 11.

More Python Programming questions

Exams that ask this topic