Skip to content

Python round() Function

  • by

Python round() Function is used to get a number rounded to the specified number of decimals. This method rounds off the digits of a number and returns the floating-point number.

round(number, digits) 

Note: The default number of decimals is 0

Python round() Function

Simple example code round number if the second parameter is missing.

# for integers
print("int", round(10))

# for floating point
print("flot", round(10.7))

# even choice
print("even", round(5.5))


Python round() Function

Round a number to the given number of decimal places

    print(round(2.665, 2))  
    # cannot be represented exactly as a float  
    print(round(2.675, 2))  



Do comment if you have any doubts or suggestions on this Python function topic.

Note: IDE: PyCharm 2021.3.3 (Community Edition)

Windows 10

Python 3.10.1

All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.

Leave a Reply

Your email address will not be published. Required fields are marked *