Skip to Content
Menu
This question has been flagged
2 Replies
6463 Views

i to all,

how to round 2 decimals, even if the value are 00

example : 12.00 

can i do this on python

regards 

Avatar
Discard

We can achieve using python using help of "%.2f" format specifier. Can you explain more your requirement ? where you want to put 2 decimal ? i.e. inside any report or inside any web form etc...

Best Answer

Python only displays what's needed, so it displated 10.0

If it's the matter of printing it as 10.00.

To do that.

>>> d = 10
>>> print "Value: %.2f" % float(d)
Value: 10.00
>>>

Hope this will help you.

Avatar
Discard
Author

thanks Parikshit :)

Related Posts Replies Views Activity
1
Jan 24
3463
1
Aug 15
2175
2
Mar 15
3333
1
Mar 15
30318
1
Mar 15
3154