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

node.js - NodeJS remote terminal to Dropbear OpenWRT-Server -

Qt4: how to send QString inside a struct via QSharedMemory -

node.js - On Gitbash - Bower : ENOGIT git is not installed or not in the PATH -