I was wondering if there was a function built into Python that can determine the distance between two rational numbers but without me telling it which number is larger. e.g.
abs(x-y) will do exactly what you're looking for:
abs(x-y)
In [1]: abs(1-2) Out[1]: 1 In [2]: abs(2-1) Out[2]: 1