Answers for "declare matrix in python"

1

python create n*n matrix

# Creates a list containing 5 lists, each of 8 items, all set to 0
w, h = 8, 5;
Matrix = [[0 for x in range(w)] for y in range(h)]
Posted by: Guest on September-28-2020
3

numpy matrix in python 3

np.matrix([[1, 2], [3, 4]])

# matrix([[1, 2],
#         [3, 4]])
Posted by: Guest on September-27-2020

Python Answers by Framework

Browse Popular Code Answers by Language