Python abs() method is a built-in method. It is used to get absolute value of a number. It returns absolute value of a number that can be an integer, float, or a complex value. It takes single argument and if the argument is a complex number, it returns magnitude of the number.
Parameter | Description |
---|---|
x | (Required) This argument can be an integer, float or a complex number. |
It returns an absolute value of the specified number.
  If the argument is an integer, it returns integer absolute value.
  If the argument is a floating point value, it returns float absolute value.
  If the argument is a complex number, it returns magnitude.
Let’s first understand, how this method works and what it returns?
If the argument is a complex number, method returns magnitude only. See, the below example.