For numbers like 10.5, round(10.5) gives 10. 5 should round up, not down. Is there a better built-in function.
Note:
> .5 - Round up
< .5 - Round down
For numbers like 10.5, round(10.5) gives 10. 5 should round up, not down. Is there a better built-in function.
Note:
> .5 - Round up
< .5 - Round down
Python uses "banker's rounding" for x.5. Even numbers round down, odd numbers round up. You are saying it "should" round up, but that's just your definition. It's not the only definition.
If you always want rounding up, do:
result = int(x+0.5)