[python] How to implement linear interpolation?