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.
If you have an array, you can also use numpy.diff:
import numpy as np a = [1,5,6,8] np.diff(a) Out: array([4, 1, 2])