ProgrammingHardProduct-company MCQ pattern

What is printed?

What is printed?
x = -17
print(x // 5, x % 5, divmod(x, -5), x.__mod__(5))
  1. A. -4 3 (3, -2) 3
  2. B. -3 -2 (3, -2) 3
  3. C. -4 3 (2, 3) 3
  4. D. -4 3 (3, -2) -2

Correct answer: A. -4 3 (3, -2) 3

-17 // 5 floors to -4 and -17 % 5 takes the divisor's sign, giving 3. divmod(-17, -5) gives (3, -2) because -17 = 3 * (-5) + (-2).

More Python Programming questions

Exams that ask this topic