Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Return the ceil of the inputs in Numpy
To return the ceil of the input, use the numpy.ceil() method in Python Numpy. The ceil of the scalar x is the smallest integer i, such that i >= x. It is often denoted as $\mathrm{\lceil X \rceil}$. The function returns the ceil of each element in x, with float dtype. This is a scalar if x is a scalar.
The out is a location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
Steps
At first, import the required library −
import numpy as np
To return the ceil of the input, use the numpy.ceil() method in Python Numpy
Check ceil() for float −
print("Result? ", np.ceil(55.8))
print("\nResult? ", np.ceil(-599.2))
Check ceil() for inf −
print("\nResult? ", np.ceil(-np.inf))
Check ceil() for nan and inf −
print("\nResult? ", np.ceil(np.nan))
print("\nResult? ", np.ceil(np.inf))
Check ceil() for log −
print("\nResult? ", np.ceil(np.log(1)))
print("\nResult? ", np.ceil(np.log(2)))
Example
import numpy as np
# To return the ceil of the input, use the numpy.ceil() method in Python Numpy
print("Returning the ceil value...
")
# Check ceil() for float
print("Result? ", np.ceil(55.8))
print("\nResult? ", np.ceil(-599.2))
# Check ceil() for inf
print("\nResult? ", np.ceil(-np.inf))
# Check ceil() for nan and inf
print("\nResult? ", np.ceil(np.nan))
print("\nResult? ", np.ceil(np.inf))
# Check ceil() for log
print("\nResult? ", np.ceil(np.log(1)))
print("\nResult? ", np.ceil(np.log(2)))
Output
Returning the ceil value... Result? 56.0 Result? -599.0 Result? -inf Result? nan Result? inf Result? 0.0 Result? 1.0
