# numpy.absolute () in Python

| | | | | | | | | | | | | | | |

👻 Check our latest review to choose the best laptop for Machine Learning engineers and Deep learning tasks!

Parameters :

`  arr:   [array_like]  Input array or object whose elements, we need to test. `

Return:

` An array with absolute value of each array. `

Code # 1: Work

 ` # Python program explaining ` ` # absolute () function ` ` import ` ` numpy as np ` ` ` ` arr1 ` ` = ` ` [` ` 1 ` `, ` ` - ` ` 3 ` `, ` ` 15 ` `, ` ` - ` ` 466 ` `] ` ` print ` ` (` ` "Absolute Value of arr1:" ` `, ` ` np.absolute (arr1)) ` ` ` ` arr2 ` ` = ` ` [` ` 23 ` `, ` ` - ` ` 56 ` `] ` ` print ` ` (` `" Absolute Value of arr2: "` `, ` ` ` ` np.absolute (arr2)) `

Output:

` Absolute Value of arr1: [1 3 15 466] Absolute Value of arr2: [23 56] `

Code # 2: Working with complex numbers

 ` # Python program explained ` ` # absolute () function ` ` import ` ` numpy as np ` ` ` ` a ` ` = ` ` 4 ` ` + ` ` 3j ` ` print ` ` (` ` "Absolute (4 + 3j):" ` `, ` ` np.absolute (a)) ` ` b ` ` = ` ` 16 ` ` + ` ` 13j ` ` print ` ` ( ` ` "Absolute value (16 + 13j):" ` `, ` ` np.absolute (b)) `

Output:

` Absolute (4 + 3j): 5.0 Absolute value ( 16 + 13j): 20.6155281281 `

Code # 3: Graphical representation of numpy.absolute ()

 ` # Python program explaining ` ` # absolute () function ` ` import ` ` numpy as np ` ` import ` ` matplotlib.pyplot as plt ` ` a ` ` = ` ` np.linspace (start ` ` = ` ` - ` ` 5 ` `, stop ` ` = ` ` 5 ` `, ` ` num ` ` = ` ` 6 ` `, endpoint ` ` = ` ` True ` `) ` ` print ` ` (` ` "Graphical Representation:" ` `, ` ` np.absolute (a)) ` ` plt.title (` ` "blue: with absolute red: without absolute "` `) ` ` plt.plot (a, np.absolute (a) ) ` ` plt.plot (a, a, color ` ` = ` ` ’red’ ` `) ` ` plt.show () `

Output:

` Graphical Representation: [5. 3. 1. 1 . 3. 5.] `

## Shop Learn programming in R: courses

\$FREE Best Python online courses for 2022

\$FREE Best laptop for Fortnite

\$399+ Best laptop for Excel

\$ Best laptop for Solidworks

\$399+ Best laptop for Roblox

\$399+ Best computer for crypto mining

\$499+ Best laptop for Sims 4

\$

Latest questions

PythonStackOverflow

Common xlabel/ylabel for matplotlib subplots

PythonStackOverflow

Check if one list is a subset of another in Python

PythonStackOverflow

How to specify multiple return types using type-hints

PythonStackOverflow

Printing words vertically in Python

PythonStackOverflow

Python Extract words from a given string

PythonStackOverflow

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

PythonStackOverflow

Python os.path.join () method

PythonStackOverflow

Flake8: Ignore specific warning for entire file

## Wiki

Python | How to copy data from one Excel sheet to another

Common xlabel/ylabel for matplotlib subplots

Check if one list is a subset of another in Python

How to specify multiple return types using type-hints

Printing words vertically in Python

Python Extract words from a given string

Cyclic redundancy check in Python

Finding mean, median, mode in Python without libraries