Home >>Python math Module >Python math.fabs() Method
Python math.fabs() method in python returns an absolute value of a number in the float type and it accepts a number (either positive/ negative integer).
Syntax:math.fabs(x)
Parameter | Description |
---|---|
x | It is required a number to return the absolute value |
import math
print(math.fabs(-21.34))
print(math.fabs(-2))
import math
w = -23
x = 45
y = -15
z = 35
print("fabs(w): ", math.fabs(w))
print("fabs(x): ", math.fabs(x))
print("fabs(y): ", math.fabs(y))
print("fabs(z): ", math.fabs(z))