ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
print(sum(divmod(17, 5)), divmod(-17, 5)[1], 17 % 5 - (-17) % 5)
  1. A. 6 3 -5
  2. B. 5 3 -1
  3. C. 5 2 5
  4. D. 5 3 5

Correct answer: B. 5 3 -1

divmod(17, 5) is (3, 2), and their sum is 5. -17 % 5 is 3. The last term is 17 % 5 - (-17) % 5 = 2 - 3 = -1.

More Python Programming questions

Exams that ask this topic