Operator Functions

operator.abs()

Return the absolute value or magnitude using the absolute-value protocol.

Formal Syntax & Structure

python syntaxpython
operator.abs(obj, /)

Parameters & Attributes

NameTypeDescription
objobjectObject to inspect or copy.

Return Value

object

The object result described above.

Working Example

Example Snippetpython
import operatorprint(operator.abs(-8))
Python Reference