def Lagrange(Lx, Ly):
    X = sympy.symbols('X')
if len(Lx) != len(Ly):
    print('ERROR')
return 1
y = 0
for k in range(len(Lx)):
    t = 1
for j in range(len(Lx)):
    if j != k:
        t = t * ((X - Lx[j]) / (Lx[k] - Lx[j]))
y += t * Ly[k]
return y
Lagrange interpolation in Python: as a result matematical formula