NumPy is a third-party, open-source library in Python that supports mathematical, scientific, and Data Science programming.
Numpy provides an n-dimensional
NumPy can be imported in Python using
import numpy as np
np.abs(array)
: To calculate absolute value of each value of the array.np.sqrt(array)
: To calculate square root of each value of the array.np.exp(array)
: To calculate exponential value of each element of the array.np.square(array)
: To calculate square of each value of the array.np.sin(array)
: To find the sine value of each data in the array.np.cos(array)
: To find the cos value of each data in the array.np.tan(array)
: To find the tan value of each data in the array.import numpy as np# Defining a numpy array:# array 1:arr = np.array([3,4,-2,5,1,-5,25,-6,9])# array 2:arr1= np.array([4,16,64,25])# Working with some numpy uniary ufuncs:# 1. abs, fabs:print(f"Absolute values: {np.abs(arr)}")# 2. sqrt:print(f"Square root of each element: {np.sqrt(arr1)}")# 3. exp:print(f"Exponential value for each element: {np.exp(arr1)}")# 4. square:print(f"Squared values: {np.square(arr)}")# 5. sin:print(f"Sine value: {np.sin(arr1)}")# 6. cos:print(f"Cos value: {np.cos(arr1)}")# 7. tan:print(f"Tan value: {np.tan(arr1)}")# Similarly other uniary functions can be applied.
Click on the below link to know more about ufuncs: