You can download this code by clicking the button below.
This code is now available for download.
Calculate the absolute difference between two numbers.
Technology Stack : Built-in function abs(), used to get the absolute value.
Code Type : Mathematical calculation
Code Difficulty :
def abs_diff(x, y):
"""
Calculate the absolute difference between two numbers.
Parameters:
x (int or float): The first number.
y (int or float): The second number.
Returns:
int or float: The absolute difference between x and y.
"""
return abs(x - y)