Round float to 2 decimal places Python | Example code

Use the round function to Round float to 2 decimal places in Python. This method takes as its first argument the number and the second argument is the precision after the decimal point.

round(number, digits) 

Example Round float to 2 decimal places Python

Simple example code rounds down to 2 and 3 decimals a float using Python.

print(round(1.4756, 2))

print(round(1.3339, 3))

Output:

Round float to 2 decimal places Python

Do comment if you have any doubts and suggestions on this Python float topic.

Note: IDE: PyCharm 2021.1.3 (Community Edition)

Windows 10

Python 3.7

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


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.