Python fabs() is an inbuilt math function that is used to get the absolute value of a number. It first finds the absolute value, and it converts the number into a float type number, no matter whether the given number is an integer or float. The fabs() method is under the math library in Python, which means we have first to import math to use this method.

Python fabs() Method

Python fabs() function is one of the Math function that returns the absolute value ((Positive value) of the particular expression or a specific number.

Syntax

math.fabs(number)

The fabs() method takes one parameter, the number whose absolute value will be returned.

number: It can be a number or a valid numerical expression for which you want to find an absolute value in Python.

  • If a number argument is the positive or negative number, the fabs() function will return the absolute value.
  • If a number argument is not a number, fabs() function will return TypeError.

#python #python fabs

Python fabs() Method Example | Python math functions
3.30 GEEK