ProgrammingVery hardGATE CS & IT · Infosys

What is printed?

What is printed?
print(divmod(-9, 4), -9 % 4, round(-9 / 4))
  1. A. (-2, 1) 3 -2
  2. B. (-3, 3) -1 -3
  3. C. (-3, 3) 3 -3
  4. D. (-3, 3) 3 -2

Correct answer: D. (-3, 3) 3 -2

divmod and % floor the quotient, so -9 divided by 4 gives -3 with remainder 3. round(-2.25) rounds to the nearest integer, which is -2.

More Python Programming questions

Exams that ask this topic