Program to create a 2×3 matrix using NumPy.

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

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

x.reshape(2,3)
				
			

Output :

				
					array([[0, 1, 2],
       [3, 4, 5]])
				
			

create a 3×4 matrix.

create a 2×2 matrix

Leave a Comment