ProgrammingVery hardInfosys HackWithInfy · TCS CodeVita

What does the following Python 3 code print? print(round(2.5), round(3.5), round(2.675, 2))

  1. A. 2 4 2.68
  2. B. 3 4 2.68
  3. C. 3 4 2.67
  4. D. 2 4 2.67

Correct answer: D. 2 4 2.67

Python's round() uses banker's rounding to the nearest even digit for exact halfway floats (2.5->2, 3.5->4); 2.675 isn't exactly representable in binary floating point and rounds to 2.67, not 2.68.

More Python Programming questions

Exams that ask this topic