Computer >> Computer tutorials >  >> Programming >> Python

How to find the smallest number greater than x in Python?


The built-in function ceil() returns smallest number that is greater than the given number

>>> x=6.67
>>> import math
>>> math.ceil(x)
7
>>> x=1.13
>>> math.ceil(x)
2
>>> x=5.78
>>> math.ceil(x)
6
>>> x=-5.78
>>> math.ceil(x)
-5

Note that -5 is greater than -5.78