import numpy n = 3 A = numpy.random.randint(low=1, high=10, size=(n, n)) d = numpy.linalg.det(A) print("Matrix A: \n", A) print("det(A): ", d)
Here, we are creating a matrix that contains random integers. We are using the numpy.random.randint() function for that purpose. The generated integers will be within the range [low, high). And the size=(n, n) argument specifies that the created matrix will have n rows and n columns.
Now, we are using the numpy.linalg.det() function to calculate the determinant of the matrix. The output of the mentioned program will be:
Matrix A: [[7 1 5] [6 8 5] [3 7 7]] det(A): 209.99999999999994






0 Comments