Affiliate links on Android Authority may earn us a commission.Learn more.
How to round in Python
July 07, 2025
Want to know how to round in Python? This can be useful for a wide range of applications, particularly when converting a float into an integer, or when presenting data in a readable manner.
Thankfully, this is an easy job: there are actually three separate ways to round in Python.

How to round in Python: know your options
First, you can use the built-inround()function. This will round values either up or down.math.floor(), meanwhile, will round the value down. Finally,math.ceil()will round the value up to the nearest whole.
In order to use the latter two statements, you will need to import the math module with the line:import math.
To see how this might work, use the following code:
Now hit run, and you will see the output looks like so:
As you may see, the first two options rounded down to 7, while the final option rounded up to 8. Remember: when usinground(), the value will round up whenever the value is higher than .5.
Other tricks using the math module
Now you know how to round in Python, there plenty of other neat things you can do with the math module. Some examples include:
Learn more
If you want to learn more about coding in Python, a great place to start iswith our introductory postthat will walk you through the set up process and a basic first project.
If you want to take this knowledge further though, then you should check out our list of thebest online Python courses. Any of these will provide you with a full and detailed introduction to Python that can put you on the right path to a development career. Or if you are really new and looking for the best introductory option, we highly recommendCoding with Python: Training for Aspiring Developers, which you can nab for just $49.99, which is an absolute steal as the course is valued around $700.
Thank you for being part of our community. Read ourComment Policybefore posting.