self.slopes = [((y2 - y1) / (x2 - x1)) for x1, x2, y1, y2 in intervals]

def __getitem__(self, x):
    i = bisect_left(self.x_list, x) - 1
return self.y_list[i] + self.slopes[i] * (x - self.x_list[i])
Linear Interpolation - Python