Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (50.2k points)

I can able to comprehend math.ceil and numpy.ceil, but both of them lack in the significant parameters. For example in Excel:

=Ceiling(210.63, 0.05) -> 210.65

On the other hand, the numpy.ceil and math.ceil:

numpy.ceil(210.63) -> 211.0

math.ceil(210.63) -> 211.0

So, I want to know, is there some similarities in Excel?

1 Answer

0 votes
by (108k points)

You can create your own set of user-defined function:

import math

def ceil(x, s):

    return s * math.ceil(float(x)/s)

The conversion to float is necessary for python 2 to bypass the integer division if both parameters are integers. You can also use from __future__ import division. This is not needed with python 3. 

Want to be a Python expert? Join this Python Training course by Intellipaat to learn more.

Browse Categories

...