본문 바로가기
Computer Science/[20-4] Numpy 연습

[Numpy] (6) Array Mathematics

by gojw 2020. 4. 3.

HackerRank 문제: https://www.hackerrank.com/challenges/np-array-mathematics/problem

 

Array Mathematics | HackerRank

Perform basic mathematical operations on arrays in NumPy.

www.hackerrank.com

import numpy

N,M=map(int,input().split())

A=numpy.array([list(map(int,input().split())) for n in range(N)])
B=numpy.array([list(map(int,input().split())) for n in range(N)])

print(numpy.add(A,B))
print(numpy.subtract(A,B))
print(numpy.multiply(A,B))
print(numpy.floor_divide(A, B))
print(numpy.mod(A,B))
print(numpy.power(A,B))

댓글