ProgrammingHardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
print(-5 // 2 * 2 + -5 % 2 == -5, 5 // -2 * -2 + 5 % -2 == 5)
  1. A. True False
  2. B. False False
  3. C. True True
  4. D. False True

Correct answer: C. True True

Python keeps the identity (a // b) * b + a % b == a for both signs, so each side equals the original number. The checks are True.

More Python Programming questions

Exams that ask this topic