check if there is a certain number difference with python 1

check if there is a certain number difference with python

In [1]: abs(1-2)
Out[1]: 1

In [2]: abs(2-1)
Out[2]: 1

Here is what the above code is Doing:
1. We are defining a function called `abs_diff` that takes two arguments, `x` and `y`.
2. We are defining a variable called `diff` that is equal to the absolute value of the difference between `x` and `y`.
3. We are returning the value of `diff`.

Now, let’s try calling our function:

In [3]: abs_diff(1,2)
Out[3]: 1

In [4]: abs_diff(2,1)
Out[4]: 1

Similar Posts