Absolute Difference Calculator

  • Share this:

Code introduction


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)