Sometimes, we want to round up a number with Python.
In this article, we’ll look at how to round up a number with Python.
How to round up a number with Python?
To round up a number with Python, we can use the math.ceil method.
For instance, we write
import math
print(int(math.ceil(4.2)))
to call math.ceil with a number to round it up.
Then we call int to convert the rounded up number to an integer.
Conclusion
To round up a number with Python, we can use the math.ceil method.