The Python built-in function "abs()" returns the absolute value of a number. The absolute value is the numerical value of a number without regard to its sign. For example, the absolute value of -5 is 5 and the absolute value of 5 is also 5. The function can be used with both integers and floating-point numbers. The general syntax for using the abs() function is:

abs(x)

where x is the number whose absolute value is to be returned.

Example

>>> abs(-5)
5
>>> abs(5)
5
>>> abs(-3.14)
3.14

Younes Derfoufi
my-courses.net
One thought on “The built-in function "abs()" in Python”

Leave a Reply