ProgrammingHardProduct-company MCQ pattern

What is printed?

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

Correct answer: D. -2 -3 3 -2

The remainder takes the sign of the divisor. -17 % -5 is -2, 17 % -5 is -3, and -17 % 5 is 3. The unary minus in the last value is applied after the % operation.

More Python Programming questions

Exams that ask this topic