ProgrammingModerateTCS NQT · Infosys

What is printed?

What is printed?
print(int(9.99), int(-9.99), round(9.99), round(-9.99), 0)
  1. A. 9 -10 10 -10 0
  2. B. 9 -9 10 -10 0
  3. C. 10 -9 10 -10 0
  4. D. 9 -9 9 -9 0

Correct answer: B. 9 -9 10 -10 0

int truncates toward zero, so 9.99 gives 9 and -9.99 gives -9. round to the nearest integer gives 10 and -10.

More Python Programming questions

Exams that ask this topic