How To Round A Float To 2 Decimal Places In Python

To round a float or decimal number to 2 decimal places in python, we can use it’s pre-built function “Round()”.

The way this function works is we can input our decimal number in the first instance separated by a comma and the number of decimal places we want our float to stop, in our case, it’s 2.

>>> round(1.23456, 2)
1.23

Because the round function takes in floats as an input, if your value is either a string or any other value, you’ll have to convert it to a float value firstly.