NumPy Basic Operations

Author: Al-mamun Sarkar Date: 2020-03-30 20:08:03

NumPy Basic Operations. In the following code, I will various NumPy array operations of Python NumPy Module.

 

import numpy as np

 

Code:

a = np.array( [20,30,40,50] )
b = np.arange( 4 )
a

Output:

array([20, 30, 40, 50])

 

Code:

b

Output:

array([0, 1, 2, 3])

 

Code:

c = a-b
c

Output:

array([20, 29, 38, 47])

 

Code:

b**2

Output:

array([0, 1, 4, 9])

 

Code:

10*np.sin(a)

Output:

array([ 9.12945251, -9.88031624,  7.4511316 , -2.62374854])

 

Code:

10*c

Output:

array([200, 290, 380, 470])

 

Code:

a<35

Output:

array([ True,  True, False, False], dtype=bool)