Python math - ceil() Function
The Python math.ceil() function returns the next highest integer value by rounding up the specified number, if necessary. In other words, it rounds the fraction UP of the given number.
Syntax
math.ceil(x)
Parameters
x |
Required. Specify a number. |
Return Value
Returns the next highest integer value by rounding UP the specified number, if necessary.
Example:
In the example below, ceil() function is used to round the fraction UP of the specified number.
import math print(math.ceil(10.5)) print(math.ceil(-10.5)) print(math.ceil(0.5)) print(math.ceil(-0.5))
The output of the above code will be:
11 -10 1 0
❮ Python Math Module