← Go Back
How to Limit Digits After the Decimal Point When Printing a Float
Using the following syntax:>>> pi = 3.14159265359
>>> print(f"{pi:.2f}") # Two decimal places.
3.14
>>> print(f"{pi:.1f}") # One.
3.1
>>> print(f"{pi:.6f}") # Six.
3.141593
🐍 You might also find interesting: