How to find absolute value in python?

Absolute value is defined as if point mapped on two dimensional XY axis; it is the distance from the origin. Remember, it is always positive. In this article, we will discuss how we can find absolute value in python.

Short Tutorial: Introduction to Python

Now which function we used to identify the absolute number in python?

abs() is the function available in python to calculate the absolute number.

math.fabs() is another function available to calculate the absolute number but as a floating type.


>>abs(value) #value is a parameter 
>>math.fabs(value) #value is a parameter

Short Tutorial: Variable and Data Types in Python

Examples of finding absolute value in python

  • Absolute number of positive integer
  • Absolute number of negative integer - it returns positive integer by dropping negative sign
  • Absolute value of complex number - it returns magnitude of complex number

  • What if calculation happens inside abs() function - it solves the equation and return positive numeral
  • absolute value of positive floating value - it returns the same value
  • absolute value of negative floating value - it returns the same value by dropping the negative sign)

Short Tutorial: Tuples, Sets and Dictionaries in Python

math.fabs() examples

>>import math

Note: math.fabs() not able to identify absolute value of complex number.


abs() and math.fabs() are two in-built python functions that we can use to calculate the absolute number.

Subscribe us to receive more such articles updates in your email.

If you have any questions, feel free to ask in the comments section below. Nothing gives me greater joy than helping my readers!

Disclaimer: This tutorial is for educational purpose only. Individual is solely responsible for any illegal act.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *