Skip to content

Commit 5e02d9c

Browse files
committed
Numpy Arithmetic Operations.py
1 parent 7634ad5 commit 5e02d9c

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Author: OMKAR PATHAK
2+
3+
import numpy as np
4+
5+
firstArray = np.arange(12).reshape(3, 4)
6+
print(firstArray)
7+
8+
secondArray = np.arange(4)
9+
print(secondArray)
10+
11+
# adding above two arrays (NOTE: array shapes should be same)
12+
print(np.add(firstArray, secondArray))
13+
14+
# subtracting above two arrays
15+
print(np.subtract(firstArray, secondArray))
16+
17+
# multiplying above two arrays
18+
print(np.multiply(firstArray, secondArray))
19+
20+
# dividing the above two arrays
21+
print(np.divide(firstArray, secondArray))
22+
23+
# numpy.power(): returns array element raised to the specified value result
24+
array = np.array([1, 2, 3])
25+
print(np.power(array, 2)) # [1 4 9]

0 commit comments

Comments
 (0)