NumPy – Arithmetic Operations:
In Numpy, we can perform various Arithmetic calculations using the various functions like add, reciprocal, negative, multiply, divide, power, substract, remainder etc.
add: This will return the addition of arguements, element-wise.
multiply: This will return the multiplication of arguements, element-wise.
divide: This will return the division of arguements, element-wise.
power: This will return the result of first array elements raised to powers from second array, element-wise.
remainder: This will return the addition of arguements, element-wise.
Example:
>>> import numpy as np >>> x=np.add(10,20) >>> print(x) 30 >>> x=np.multiply(10,20) >>> print(x) 200 >>> x=np.divide(10,20) >>> print(x) 0.5 >>> x=np.power(10,2) >>> print(x) 100 >>> x=np.remainder(10,2) >>> print(x) 0 >>> x=np.remainder(9,2) >>> print(x) 1