# Linear Algebra in Python HackerRank Solution Hello Programmers, In this post, you will know how to solve the Linear Algebra in Python HackerRank Solution. This problem is a part of the HackerRank Python Programming Series.

One more thing to add, don’t directly look for the solutions, first try to solve the problems of Hackerrank by yourself. If you find any difficulty after trying several times, then you can look for solutions.

## Linear Algebra in Python HackerRank Solutions

### Problem

The NumPy module also comes with a number of built-in routines for linear algebra calculations. These can be found in the sub-module linalg. linalg.det The linalg.det tool computes the determinant of an array.

```print numpy.linalg.det([[1 , 2], [2, 1]])       #Output : -3.0
```

linalg.eigThe linalg.eig computes the eigenvalues and right eigenvectors of a square array.

```vals, vecs = numpy.linalg.eig([[1 , 2], [2, 1]])
print vals                                      #Output : [ 3. -1.]
print vecs                                      #Output : [[ 0.70710678 -0.70710678]
#          [ 0.70710678  0.70710678]]
```

linalg.invThe linalg.inv tool computes the (multiplicative) inverse of a matrix.

```print numpy.linalg.inv([[1 , 2], [2, 1]])       #Output : [[-0.33333333  0.66666667]
#          [ 0.66666667 -0.33333333]]
```

Other routines can be found here

You are given a square matrix A with dimensions NXN. Your task is to find the determinant. Note: Round the answer to 2 places after the decimal.

#### Input Format :

The first line contains the integer N.
The next N lines contains the N space separated elements of array A.

#### Output Format :

Print the determinant of A.

```2
1.1 1.1
1.1 1.1
```

`0.0`

### Linear Algebra in Python HackerRank Solutions

```import numpy
N = int(input())
A = numpy.array([input().split() for _ in range(N)], float)
print(round(numpy.linalg.det(A),2))```

Disclaimer: The above Problem (Linear Algebra in Python) is generated by Hackerrank but the Solution is Provided by BrokenProgrammers. This tutorial is only for Educational and Learning purposes.