ProgrammingModerateTCS NQT · Wipro pattern

What is printed?

What is printed?
print(float('3.0') == 3, int(float('3.9')), round(3.5) + round(4.5), 3 == 3.0 == 3)
  1. A. True 3 9 False
  2. B. False 4 8 True
  3. C. True 3 8 True
  4. D. True 4 8 False

Correct answer: C. True 3 8 True

float('3.0') equals 3, and int(float('3.9')) truncates to 3. Round half to even gives 4 for 3.5 and 4 for 4.5, so the total is 8. Chained equality holds.

More Python Programming questions

Exams that ask this topic