Python – format() Function

Any floating-point value may contain an arbitrary number of decimal places, so it is always recommended to use the built-in format() function to produce a string version of a number with a specific number of decimal places.

Example:

# Without using format()
float(16/(float(3)))
5.3333333333333

# With using format()
format( float(16/(float(3))) , ‘2f’)
‘5.33’


You Missed

Also Checkout