Python abs() Function

Last Update : 16 Nov, 2022 Python, Programming, Example

This is a Python built-in function tutorial. In this tutorial, you will teach to use the Python abs() function with examples.

The Python abs() function return the absolute value of the given number and also removes the negative sign of a number in Python. 

When the given number is a complex number, the abs() function returns the magnitude of a given complex number.

 

Python abs() Function Syntax

The following shows the syntax of the abs() function.

Syntax: abs(number)

This function takes a single argument.

number -: This is a required argument. This argument accepts an Integer, a floating-point number, or a complex number.

 

Python abs() Function Example

Example 01: Get the absolute value of an integer number

# An integer value
x = -100
print('Absolute value is:', abs(x))

 

You found this tutorial / article valuable? Need to show your appreciation? Here are some options:

01. Spread the word! Use following buttons to share this tutorial / article link on your favorite social media sites.

02. Follow us on Twitter, GitHub ,and Facebook.