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

python - jinja2: TemplateSyntaxError: expected token ',', got 'string' -

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

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