ProgrammingModerateTCS NQT · Infosys

What is printed?

What is printed?
print(int(3.9999999999999999), int(-3.7), round(-3.7))
  1. A. 3 -3 -4
  2. B. 4 -4 -4
  3. C. 4 -3 -4
  4. D. 4 -3 -3

Correct answer: C. 4 -3 -4

The literal 3.9999999999999999 is the same double as 4.0, so int gives 4. int truncates toward zero, giving -3, while round(-3.7) rounds to the nearest integer, giving -4.

More Python Programming questions

Exams that ask this topic