Answers for "python create a matrix with one in diagonal"

1

python create a matrix with one in diagonal

# Create a matrix in python and fill
import numpy as np
a = np.zeros((3, 3), int) # Create matrix with only 0
np.fill_diagonal(a, 1) # fill diagonal with 1
print(a)
Posted by: Guest on January-02-2021

Code answers related to "python create a matrix with one in diagonal"

Python Answers by Framework

Browse Popular Code Answers by Language