+ 2

Which function rounds off to the nearest whole number not decimal.

python 3 round to the nearest whole number. e.g from 1060 to 1000 from 1600 to 2000 from 120 to 100 in python. the round () is tricking me up.

5th Jan 2020, 7:39 PM
OkomoJacob
OkomoJacob - avatar
2 Respostas
+ 4
Jarvis2030🇰🇪 1100, 1000, 1600, 2000 all are whole numbers. If you want a floating point number to be rounded off, then round() is the best option.
5th Jan 2020, 7:42 PM
XXX
XXX - avatar
+ 3
round doesn't round off, it rounds up or down, depending. You should use floor from math instead.
5th Jan 2020, 8:13 PM
HonFu
HonFu - avatar