python absolute value

The abs() function returns the absolute value of the given number in Python. The abs() function takes an argument which is the number that you want to get the absolute value. The argument value can be:

  • An integer number (negative or positive)
  • A float number (negative or positive)
  • A complex number


Following is the syntax for abs() method −


  • x − This is a numeric expression.

Return Value

This method returns absolute value of x.


The following example shows the usage of abs() method.


When we run above program, it produces following result −

[Total: 1    Average: 5/5]
Leave a Reply

Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages