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

PythonServer Side ProgrammingProgramming

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

raja
Published on 05-Mar-2018 23:57:59
Advertisements