Round to Two Decimals in Python

Round to Two Decimals in Python

Minahil Noor Aug-10, 2021 Oct-22, 2020 Python Python Float

This article will introduce a method to round to two decimals in Python. It is the round() function.

Round to Two Decimals Using the round() Function in Python

We can use the built-in function round() in Python to round to two decimal places. The correct syntax to use this function is as follows:

round(decimalNumber, significantDigits)

This function accepts two parameters. The detail of its parameters is as follows:

Parameters Description
decimalNumber mandatory It is the decimal or float number that we want to round.
significantDigits optional It is the number of digits that we want after the decimal point.

The program below shows how we can use this method to round to two decimal places in Python.

myNumber = 1.237437874376
myRoundNumber = round(myNumber, 2)



The function has rounded the number to two decimal places.

Related Article - Python Float

  • Find Maximum Float Value in Python
  • Fix Float Object Is Not Callable in Python
  • Convert a String to a Float Value in Python
  • Check if a String Is a Number in Python
  • Convert String to Decimal in Python
  • Convert List to Float in Python