0

Why does round(2.5) return 2?

Using python 3 round(2.5) # 2 Shouldn't it return 3? I tried using python 2 and it gave me the correct result round(2.5) # 3

17th May 2020, 2:08 PM
Arian_s_k
Arian_s_k - avatar
3 Respuestas
+ 6
Found this in the python documentation: if two multiples are equally close, rounding is done toward the even choice  Try print(round(3.5)) it is 4. Or try this: for i in range (0, 100): print(round(i + 0.5))
17th May 2020, 2:22 PM
Paul
Paul - avatar
+ 2
Arian_s_k https://code.sololearn.com/cRs3RbKxgq25/?ref=app click and press RUN. It help you know about all function:)
17th May 2020, 3:22 PM
Petr