Print every element of an array using NumPy

In this python numpy program, we will print every element of an array using NumPy.

Steps to solve the program
  1. Import the numpy library as np.
  2. Create an array using np.array().
  3. Use for loop with np.nditer() to print every element of the given array.
  4. Print the output.
				
					import numpy as np
x = np.array([[4,8,0],[2,0,6]])

for ele in np.nditer(x):
    print(ele,end=' ')
				
			

Output :

				
					4 8 0 2 0 6
				
			

make an array immutable i.e. read-only.

print squares of all the elements of an array.

Leave a Comment