Skip to content

Commit b129476

Browse files
committed
Numpy 11-15
1 parent 293c996 commit b129476

File tree

5 files changed

+32
-0
lines changed

5 files changed

+32
-0
lines changed

Numpy/Dot and Cross.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Dot and Cross
2+
# https://www.hackerrank.com/challenges/np-dot-and-cross/problem
3+
4+
import numpy
5+
n = int(input().strip())
6+
a, b = (numpy.array([input().split() for _ in range(n)], int) for _ in range(2))
7+
print(numpy.dot(a, b))

Numpy/Inner and Outer.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Inner and Outer
2+
# https://www.hackerrank.com/challenges/np-inner-and-outer/problem
3+
4+
import numpy
5+
a, b = (numpy.array(input().split(), int) for _ in range(2))
6+
print(numpy.inner(a, b), numpy.outer(a, b), sep = '\n')

Numpy/Linear Algebra.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Linear Algebra
2+
# https://www.hackerrank.com/challenges/np-linear-algebra/problem
3+
4+
import numpy
5+
n = int(input().strip())
6+
a = numpy.array([input().split()[:n] for _ in range(n)], float)
7+
print(numpy.linalg.det(a))

Numpy/Mean, Var, and Std.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Mean, Var, and Std
2+
# https://www.hackerrank.com/challenges/np-mean-var-and-std/problem
3+
4+
import numpy
5+
n, m = map(int, input().split())
6+
a = numpy.array([input().split()[:m] for _ in range(n)], int)
7+
print(numpy.mean(a, axis = 1), numpy.var(a, axis = 0), numpy.std(a), sep = '\n')

Numpy/Polynomials.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Polynomials
2+
# https://www.hackerrank.com/challenges/np-polynomials/problem
3+
4+
import numpy
5+
print(numpy.polyval(numpy.array(input().split(), float), int(input().strip())))

0 commit comments

Comments
 (0)