Important Notice:

Course Content
NumPy Basic in Python (Chapter-13) M3-R5
About Lesson

Arithmetic Operation on Array:-

 

Adding Two Array

import numpy as np

a=np.array([1,2,3,4])

b=np.array([5,6,7,8])

c=a+b

print(c)

Output

[ 6  8 10 12]

 

Operation on Two Dimensional Array

import numpy as np

a=np.array([1,2,3,4]).reshape(2,2)

b=np.array([5,6,7,8]).reshape(2,2)

print(“Reshape array is “)

print(a)

print(b)

print(a+b)

print(b-a)

print(a*b)

print(b/a)

Output

 

Multiply Two Matrix

import numpy as np

a=np.array([1,2,3,4]).reshape(2,2)

b=np.array([5,6,7,8]).reshape(2,2)

print(a.dot(b))

Output

[[19 22]

 [43 50]]

 

error: Content is protected !!