How to create a matrix in python?
A matrix is a two dimensional data structure which stores data in a form of array. It is also known as 2D array.
Now we’ll see how we create matrix in python.
In python, we have a number of libraries which have different uses in different part of programming. Numpy is also a library by which we can create matrix in python.
By importing numpy in python we can easily create matrix in python.
import numpy as np a=np.matrix([[1, 2, 3], [2, 3, 4], [5, 6, 7]]) print(a)
In this way we can create matrix in python.
Please login to comment
View all comments