Calculate up to two decimal places in Python -




this question has answer here:

i want calculate 2 decimal places in calculations can't

for example:

a = 93 b = 1 c = float(93/1) print c 

i want print :

93.00 

but print :

93.0 

is there function or there way this?

use explicit format float

print("%.2f" % round(c,2)) 

test on jupyter

https://try.jupyter.org/


enter image description here





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -

python - Read npy file directly from S3 StreamingBody -