What is the output of the following Python code? print(round(2.5), round(3.5))
Correct answer B. 2 4
Explanation
The built-in round() uses round half to even, also called banker's rounding: when a value is exactly halfway between two integers it rounds to the even one. So 2.5 rounds to 2 and 3.5 rounds to 4. Expecting 3 for 2.5 comes from the school rule of always rounding halves up.
Answer checked How we write and check questions
Discussion