ProgrammingVery hardTCS NQT · Accenture

What is printed?

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

Correct answer: C. 3.0 3.0 -4.0 2.0

7 / 2 is 3.5 and floor division by 1 gives 3.0. -7 / 2 is -3.5, which floors to -4.0. 7 % 2.5 is 2.0.

More Python Programming questions

Exams that ask this topic