How to round down to 2 decimals a float using Python?

PythonServer Side ProgrammingProgramming

Python's round() function requires two arguments. First is the number to be rounded. Second argument decides the number of decimal places to which it is rounded. To round the number to 2 decimals, give second argument as 2. If third digit after decimal point is greater than 5, last digit is increased by 1.

>>> round(1.4756,2)
1.48
>>> round(1.3333,2)
1.33
raja
Published on 06-Mar-2018 19:51:20
Advertisements