ProgrammingVery hardProduct-company MCQ pattern

What is printed?

What is printed?
print(7 // 1.0 * 1, 1e3 // 7, -1e3 // 7, 10 % -3.0)
  1. A. 7 142.0 -143.0 -2.0
  2. B. 7.0 142.0 -142.0 -2.0
  3. C. 7.0 142.0 -143.0 -1.0
  4. D. 7.0 142.0 -143.0 -2.0

Correct answer: D. 7.0 142.0 -143.0 -2.0

Any float operand makes // and % return floats. 1000 // 7 is 142.0, while -1000 // 7 floors to -143.0. A negative divisor gives the remainder a negative sign, so 10 % -3.0 is -2.0.

More Python Programming questions

Exams that ask this topic