This is a detailed tutorial of the NumPy Simple Arithmetic Universal Functions. Learn the usage of these functions with the help of examples.

Table of Contents

Simple Arithmetic

As we all know, we have various arithmetic operators that are helpful in data modification of NumPy arrays. So in this section, we will discuss some functions which will take in the array-like objects e.g. lists and tuples and will use the arithmetic functions which will work under some conditions. Conditions will work in such a way that we define that on what condition an arithmetic operation will work.

In order to apply these conditions, we use a parameter known as where which helps in specifying the condition. This condition will act as the basis on which the arithmetic function will work upon. Let us discuss some of the arithmetic function:

Addition:

This function helps in the addition of the NumPy arrays. This will return us the result in the new array. The add()  function will help us in performing this operation.

So let us go through an example to understand it better:

Subtraction

In this function, we will perform the functionality of subtraction where will subtract one NumPy array from another. The function used for this is subtract(). This function will help in subtracting and the result will come in a new array.

#programming #python #numpy #numpy universal functions #ufuncs #function

Simple Arithmetic - NumPy uFuncs (Python Tutorial) - WTMatter
2.80 GEEK