1. Home
  2. Python
  3. Python Functions
  4. Python abs() Function

Python abs() Function

Python abs() Function

The Python abs() method returns the absolute value of a number. It accept one argument of type integer or a floating point number. If the input argument is a complex number, its returns the magnitude.

Example 1.

Below is the sample Python program to calculate the absolute value of a integer and floating point number. Write the below script in a python script:

Run the script and see the output:

10
3.638

Example 2.

Here is another example of calculating absolute value of a complex number. In result, you will get the magnitude of the number.

Create another Python script and write below value.

Run the script and see the output:

13.0
Tags