Feb-21-2023, 04:38 PM
Do you want to round numbers to some precision, or do you want to format output for printing? These are two different things, and are accomplished using different tools. If all you want is to print floats with two decimal places, use one of Python's many formatters (use f'string). If you want to round the numerical value of a float to some precision, use round. Be aware that floats do not have infinite precision and rounding may not give you the exact value you want.