+ 1

# How to print a number with two zeros after a point? x2

Input: a=2.5, b=4, output: c=a*b, c= 10.00

1 Answer

+ 5

You should not be fixed to 2 zeros, because a calculation can also give a result of e.g. 12.45912316, which you may like to shorten to 12.46. To do this task you can use round() function or you can use string interpolation with formatting like this:
print(f'{12.45912316:.2f}')