NumPy Universal Functions

NumPy Universal Functions

Instructor-svg Al-Mamun Sarkar
Mar 30 , 2020

NumPy Array universal functions. The following shows various universal functions such as np.exp(), np.sqrt(), np.add() functions of the NumPy array of Python NumPy module. 

 

import numpy as np

 

Code:

B = np.arange(3)
B

Output:

array([0, 1, 2])

 

Code:

np.exp(B)

Output:

array([ 1.        ,  2.71828183,  7.3890561 ])

 

Code:

np.sqrt(B)

Output:

array([ 0.        ,  1.        ,  1.41421356])

 

Code:

C = np.array([2., -1., 4.])
np.add(B, C)

Output:

array([ 2.,  0.,  6.])
  • Share On:
  • fb
  • twitter
  • pinterest
  • instagram