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