Python Absolute Value - abs() with Examples

Python abs() function returns the absolute value of the number. It’s one of the built-in functions in python builtins module.

Python Absolute Value using abs()

Python abs() takes a single argument, which has to be a number, and returns its absolute value.

  • Integer, Long – returns absolute value.
  • Float – returns absolute value.
  • Complex – returns its magnitude
  • Numbers in different formats – returns absolute value in decimal system even if numbers are defined in binary, octal, hexadecimal or exponential form.

Python abs() with integers


Python absolute value of float


Python abs() with complex numbers


Python abs() with different format numbers


That’s all for quick examples of python absolute values of numbers using abs() function.

You can checkout complete python script and more Python examples from our GitHub Repository.

Reference: Official Documentation

By admin

Leave a Reply

%d bloggers like this: