Python abs() Function

Returns the absolute value of a number.

Syntax

Python
abs(number)

Parameters

ParameterDescription
number Required. The number whose absolute value is to be returned

Example

Python
print(f'Absolute value of -5 = {abs(-5)}')
print(f'Absolute value of 12 = {abs(12)}')

Output

Absolute value of -5 = 5
Absolute value of 12 = 12