python formate string to 2dp code example Example 1: python 2 decimal places format print "%.2f" % 5 Example 2: python 2 decimal places format "{:.2f}".format(5)