ProgrammingHardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
print(sum(range(0, 101, 5)), len(range(0, 101, 5)))
  1. A. 1050 21
  2. B. 1050 20
  3. C. 1000 21
  4. D. 1055 21

Correct answer: A. 1050 21

The values are 0, 5, ..., 100, which is 21 numbers. Their sum is 5 times 0 + 1 + ... + 20, which is 5 * 210 = 1050.

More Python Programming questions

Exams that ask this topic