Round(4.5) == 4?

At the coure,, there’s an example saying round(4.5) becomes 4, not 5. It returns 4 even at the console on the right. Shouldn’t it be 5?

Hey I believe that since we are using Python 3 in the modules, this version uses “banker’s rounding”. Banker’s rounding rounds to the nearest even number if the fractional component is halfway between two numbers. This is why 4.5 rounds to 4 and why round(5.5) returns 6.

Here’s a link for more information:

Hope this helps!

1 Like

This is a very in-depth article on this issue.

Mathematically, yes, but programming isn’t mathematics.