Program to create a 3×4 matrix using NumPy.

In this python numpy program, we will create a 3×4 matrix using NumPy.

Steps to solve the program
  1. Import the numpy library as np.
  2. Create an array of 12 elements using np.array() because 3×4 matrix will have 12 elements.
  3. Now convert the array to create a 3×4 matrix using reshape.
  4. Print the output.
				
					import numpy as np
x = np.arange(1,13)

x.reshape(3,4)
				
			

Output :

				
					array([[ 1,  2,  3,  4],
       [ 5,  6,  7,  8],
       [ 9, 10, 11, 12]])
				
			

print all the values from the above array except 1.

create a 2×3 matrix.

Leave a Comment