Python abs() Function
Returns the absolute value of a number.
Syntax
Python
Copy Code
abs(number)
Parameters
Parameter | Description |
---|---|
number |
Required. The number whose absolute value is to be returned |
Example
Python
Copy Code
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