ProgrammingHardTCS NQT · Wipro pattern

What is printed?

What is printed?
print(int(3.99), int(-3.99), round(3.5), round(4.5))
  1. A. 3 -3 4 4
  2. B. 3 -4 4 5
  3. C. 4 -3 4 4
  4. D. 3 -3 4 5

Correct answer: A. 3 -3 4 4

int truncates toward zero, so 3.99 becomes 3 and -3.99 becomes -3. round sends halves to the nearest even integer, so 3.5 goes to 4 and 4.5 goes to 4.

More Python Programming questions

Exams that ask this topic