ProgrammingModerateTCS NQT · Infosys

What is printed?

What is printed?
print(sum(range(10)) / len(range(10)), sum(range(10)) // len(range(10)), sum(range(1, 11)) % 7)
  1. A. 4.5 4 3
  2. B. 4.5 4 6
  3. C. 4.0 4 6
  4. D. 4.5 5 6

Correct answer: B. 4.5 4 6

The sum of 0 to 9 is 45, and dividing by 10 gives 4.5 with / and 4 with //. The sum of 1 to 10 is 55, and 55 mod 7 is 6.

More Python Programming questions

Exams that ask this topic