## Python absolute value – basics

An absolute value of a number describes the distance from zero that a number is on the number line. It can also be defined as the value without considering its sign. In Python the **abs() **function allows us to return the absolute value of a number.

## How to use the abs() function

The **abs()** function is a built-in function that takes in one argument and follows the syntax below.

```
abs(num)
```

Where **num **represents the number whose absolute value we want to return. This number can be an integer, floating-point number or a complex number. In this article, we will explore how to return the absolute values of these numeric types.

Please note that when using the **abs()** function on positive numbers they remain unaffected.

## Finding the Python absolute value of an Integer

An integer is a positive or negative whole number without a fractional part including zero. We are going to create two variables containing positive and negative integers of the same value named **num **and **num1. **We have also created two variables to hold the absolute values returned by the abs() function namely **abval **and **abval1**.

As shown in the output above the absolute value of **-15** is **15**, while the **15 **remains unaffected.

## Finding the Python Absolute Value of a Floating point number

A floating-point number in Python is a number with decimal points. We can also use the **abs()** function to find the absolute value of floating-point numbers. In such a scenario the abs() function returns a floating-point absolute value.

In a similar manner, the absolute value of the negative floating-point number is the number without the negative sign. While the absolute value of the positive absolute number is that same number unaffected.

### Finding the Python Absolute Value of Complex Numbers

Complex numbers consist of real and imaginary parts. The imaginary part is normally represented by appending a j after the number.

We can also use the abs() function to return the absolute values of complex numbers. In the case of complex numbers, the absolute function returns the magnitude part that can also be a floating-point number.

As mentioned the magnitude can also be a floating-point number as shown below.

### Using the max() function

We can use the abs() function to work out the largest absolute value from a list of numbers. We will also use the built-in function **max() ** which returns the item with the highest value in an iterable.

When used alone the **max()** function simply returns the highest value as shown below.

To get the number with the furthest distance from zero we have to specify the key as abs. Now when we run this we are going to get the furthest figure from zero which is **-15** in this list.

## Summary

So this is how you can use Python absolute value methods in a nutshell. If you’d like to see **more programming tutorials,** check out our **Youtube channel, **where we have plenty of Python video tutorials in English. **In our Python Programming Tutorials series,** you’ll find useful materials which will help you improve your programming skills and speed up the learning process.

## Programming tutorials

- How to use the Python for loop
- How to use Python Sets
- How to use a Python Dictionary
- How to use Python Classes
- How to use Python Range
- How to use Python if-else statements
- How to use Python RegEx
- How to use Python Lists
- How to use Python Enumerate
- How to use Python Functions
- How to use Python Split
- How to use Python Try-Except
- How to use Python Tuples
- How to use Python Arrays
- How to use Python Sort
- How to use the Python DateTime
- How to download Python?
- How to use the Python FileWrite function
- How to use Python Lambda
- How to use Python ListAppend
- How to use Python ListComprehension
- How to use Python Map
- How to use Python Operators
- How to use Python Pandas
- How to use Python Requests
- How to use Python Strings
- How to use Python Count
- How to use Python Comments
- How to use the Python File Reader method
- How to use the Python IDE-s
- How to use Python logging
- How to use Python Print
- How to use the Python Zip
- How to use Python Append
- How to use Python Global Variables
- How to use the Python join method
- How to use Python list length
- How to use Python JSON files
- How to use Python Modulo
- How to use Python file opening methods
- How to use Python round
- How to use Python sleep
- How to use Python replace
- How to use Python strip
- How to use the Python Time module
- How to use Python unittests
- How to save data to a text file using Context Manager?
- How to use Python external modules
- How to use Python find
- How to install the Python pip package manager
- How to delete files in Python
- Parsing XML files in Python
- How to make a GUI in Python
- How to use Python in Command Prompt
- How to Run a Python Program in VS Code
- How to run a program in Python IDLE
- How to run a program in Jupyter Notebook
- How to read a text file in Python
- How to add numbers in Python
- How to ask for user input in Python
- How to debug in Python
- How to create a thread in Python
- How to end a program in Python
- How to import a library in Python
- How to use the PIP package manager
- How to use classes in Python
- How to reverse strings in Python
- How to convert a string to int in Python
- How to print on the same line in Python
- How to remove items from a list
- How to add to a dictionary in Python
- How to raise an exception in Python
- How to throw an exception in Python
- How to stop a program in Python
- How to use Python assert
- How to use the Python compiler
- How to use Python decorator
- How to use the Python argparse module
- How to use Python queue
- How to use Python threading
- How to concatenate strings in Python
**How to use the Python absolute value**

Would you like to learn how to code, online? Come and try our first 25 lessons for free at the CodeBerry Programming School.