Python int() to the nearest value -


the way python int()function works rounds number smallest value.

such 4.99 = 4

what can if want 4.99 equal 5?

int() truncates float values, removing non-integral portion of number. looking rounding instead.

you can use round() function that:

>>> round(4.99) 5 

Comments

Popular posts from this blog

php - Hide output during test execution -

javascript - Migrate custom AngularJS filter from 1.2.28 to 1.4.x -

Update Magento products with multiple images -