ProgrammingHardProduct-company MCQ pattern

What is printed?

What is printed?
print(divmod(-1, 10**20), divmod(10**20, -1))
  1. A. (-1, 99999999999999999998) (100000000000000000000, 0)
  2. B. (-1, 99999999999999999999) (-100000000000000000000, 0)
  3. C. (0, -1) (-100000000000000000000, 0)
  4. D. (-1, 100000000000000000000) (-100000000000000000000, 0)

Correct answer: B. (-1, 99999999999999999999) (-100000000000000000000, 0)

-1 = (-1) * 10**20 + (10**20 - 1), which gives quotient -1 and remainder 10**20 - 1. Dividing 10**20 by -1 gives the negative quotient with remainder 0.

More Python Programming questions

Exams that ask this topic