ProgrammingHardTCS NQT · Infosys

What is printed?

What is printed?
print(divmod(7, 2.5), divmod(-7.5, 2))
  1. A. (2.0, 2.0) (-3.0, 0.5)
  2. B. (2.0, 2.0) (-4.0, 0.5)
  3. C. (2.0, 0.5) (-4.0, 0.5)
  4. D. (3.0, 0.5) (-4.0, 0.5)

Correct answer: B. (2.0, 2.0) (-4.0, 0.5)

7 divided by 2.5 is 2.8, so the floor is 2 and the remainder is 2.0. For -7.5 divided by 2 the quotient floors to -4.0, leaving a remainder of 0.5.

More Python Programming questions

Exams that ask this topic