ProgrammingHardProduct-company MCQ pattern

What is printed?

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

Correct answer: D. True True 4

For every sign combination a == (a // b) * b + a % b, so both identities hold. -7 // 2 is -4, and negating that gives 4.

More Python Programming questions

Exams that ask this topic