In this python numpy program, we will round off the elements in an array using the floor 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.floor().
- It will round up a decimal number to its base value i.e 12.5 will be 12.
- Print the output.
import numpy as np
arr = np.array([12.202, 90.23120, 123.88, 23.202])
print(np.floor(arr))
Output :
[ 12. 90. 123. 23.]