Member-only story
Hi everyone, welcome back. Today, we will be going over the abs() function in Python and see how it works. The abs() function is a built in function and its purpose is to return an absolute value of a given number. Let’s get into it.
Abs Function
Let’s see how the abs() function works:
result = abs(-3.5)
print(result)Output:
3.5
As we can see in the example above, we requested for the absolute value of -3.5 and our abs() function returned a value of 3.5, which is our expected result.
Conclusion
This is it for the abs() function example. It’s a fairly straight forward function that returns an absolute value of a given number. I hope this helps. Thanks for reading.