ProgrammingModerateProduct-company MCQ pattern

What is printed?

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

Correct answer: A. -4 1

// floors toward minus infinity: -7/2 = -3.5 floors to -4. The remainder follows a = (a // b) * b + a % b, so -7 % 2 = -7 - (-8) = 1 and takes the sign of the divisor. C would give -3 and -1.

More Python Programming questions

Exams that ask this topic