To find the ceiling of a number in Python, we can use the Python ceil() function from the math module. The math.ceil() Python function rounds a number up to the nearest integer.
import math ceiling_of_5p2 = math.ceil(5.2) print(ceiling_of_5p2) #Output: 6
The Python math module has many powerful functions which make performing certain calculations in Python very easy.
One such calculation which is very easy to perform in Python is finding the ceiling of a number.
We can find the ceiling of a number easily with the Python math module ceil() function.
Below are some examples of how to use math.ceil() in Python to round up and find the ceiling of numbers.
import math print(math.ceil(5.2)) print(math.ceil(10.8)) print(math.ceil(43.5)) print(math.ceil(-12.3)) print(math.ceil(-0.3)) #Output: 6.0 11.0 44.0 -12.0 0.0
If you are using pandas in Python you can find the ceiling of a column or Dataframe with the pandas ceil() function.
Hopefully this article has been beneficial for you to learn how to get the ceiling in Python of a number with the math.ceil() function.