ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
print(int(3.99999999999999999), int(-0.9))
  1. A. 4 0
  2. B. 3 0
  3. C. 4 -1
  4. D. 3 -1

Correct answer: A. 4 0

The literal 3.99999999999999999 is rounded to the double 4.0 before int sees it, so int gives 4. int truncates toward zero, so int(-0.9) is 0.

More Python Programming questions

Exams that ask this topic