printing till 2 decimal python code example
Example 1: print decimal formatting in python
a_float = 3.14159
formatted_float = "{:.2f}".format(a_float)
Example 2: round decimal to 2 places python
>>> round(1.4756,2)
1.48
>>> round(1.3333,2)
1.33
a_float = 3.14159
formatted_float = "{:.2f}".format(a_float)
>>> round(1.4756,2)
1.48
>>> round(1.3333,2)
1.33