Print squares of all the elements of an array using NumPy.

In this python numpy program, we will print squares of all the elements 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 np.square() to get the squares of all the elements in the given array.
  4. Print the output.
				
					import numpy as np 
x = np.array([2,6,3,1])

print("Sqaure of every element in the arrary: ",np.square(x))
				
			

Output :

				
					Sqaure of every element in the arrary:  [ 4 36  9  1]
				
			

print every element of an array.

access an array by column.

Leave a Comment