Program to round off the elements in an array using the floor function

In this python numpy program, we will round off the elements in an array using the floor function.

Steps to solve the program
  1. Import the numpy library as np.
  2. Create an array using np.array().
  3. Round off the elements in an array using np.floor().
  4. It will round up a decimal number to its base value i.e 12.5 will be 12.
  5. 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.]
				
			

round off the elements in an array up to two digits.

round off the elements in an array using ceil function.

Leave a Comment