def lininterpol(first,second,x):
    """Perform linear interpolation for x between first and second.
    
    Parameters:
    1. first: [x1, y1], where x1 is the first x value and y1 is its y value
    2. second: [x2, y2], where x2 is the second x value and y2 is its y value
    3. x: the x value whose y value will be obtained.
    
    Return:
    y
    
    """
    
    x1,y1=first
    x2,y2=second
    
    a=x-x1
    b=x2-x
    
    try:
        y=1.0*(b*y1+a*y2)/(a+b)
    except ZeroDivisionError:
        y=y1
    
    return y