Practice mode Python

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.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.