# L-10.5 MCS 260 Wed 9 Jul 2014 : q02.py
"""
Consider the following pseudocode:

    input: x, a floating point number;
           c, a list of coefficients.
    output: c[0] + c[1]*x + c[2]*x**2 + .. + c[n]*x**n,
            where n = len(c) - 1.
    result = c[0]; i = 0; n = len(c); p = x
    as long as i < n-1 do
         result = result + c[i+1]*p
         p = p * x; i = i + 1
    output result

Write a Python script that implements this pseudocode.
"""
CRAW = raw_input('give a list of coefficients : ')
C = eval(CRAW)
XRAW = raw_input('give a floating points number : ')
X = float(XRAW)
RESULT = C[0]
i = 0
N = len(C)
P = X
while i < N-1:
    RESULT = RESULT + C[i+1]*P
    P = P * X
    i = i + 1
print RESULT
