ProgrammingVery hardTCS NQT · Accenture

What is printed?

What is printed?
print(int(3.7 * 10), int(0.7 * 10), 3.7 * 10 == 37, 0.7 * 10 == 7)
  1. A. 37 7 True False
  2. B. 36 7 True True
  3. C. 37 7 True True
  4. D. 37 6 True True

Correct answer: C. 37 7 True True

3.7 * 10 rounds to exactly 37.0, and 0.7 * 10 rounds to 7.0 even though 0.7 is stored slightly below its value. Both int() conversions truncate those whole numbers unchanged.

More Python Programming questions

Exams that ask this topic