In this python numpy program, we will round off the elements in an array using ceil function.
Steps to solve the program
- Import the numpy library as np.
- Create an array using np.array().
- Round off the elements in an array using np.ceil().
- It will round up a decimal number to the next value i.e 12.5 will be 13.
- Print the output.
import numpy as np
arr = np.array([12.202, 90.23120, 123.88, 23.202])
print(np.ceil(arr)
Output :
[ 13. 91. 124. 24.]