belongs to collection: Python Array Programs

By using numpy class we can create a matrix using two ways.

mat = numpy.array([[10,20,30],[40,50,60],[70,70,90]])

mat = numpy.matrix("10 20 30; 40 50 60; 70 80 90"

Consider the below program,

# Python matrix creation using numpy # importing the numpy import numpy as np # creating matrix using numpy.array() mat1 = np.array([[10,20,30],[40,50,60],[70,70,90]]) # printing matrix print("mat1...") print(mat1) # creating matrix using numpy.matrix() mat2 = np.matrix("10 20 30; 40 50 60; 70 80 90") # printing matrix print("mat2...") print(mat2)

Output

mat1... [[10 20 30] [40 50 60] [70 70 90]] mat2... [[10 20 30] [40 50 60] [70 80 90]]

total answers (1)

start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.

Consider the below program,

need an explanation for this answer? contact us directly to get an explanation for this answerOutput