poly

The poly tool returns the coefficients of a polynomial with the given sequence of roots.

print numpy.poly([-1, 1, 1, 10])        #Output : [  1 -11   9  11 -10]

roots  

The roots tool returns the roots of a polynomial with the given coefficients.

print numpy.roots([1, 0, -1])           #Output : [-1.  1.]

polyint

The polyint tool returns an antiderivative (indefinite integral) of a polynomial.

print numpy.polyint([1, 1, 1])          #Output : [ 0.33333333  0.5         1.          0.        ]

polyder    

The polyder tool returns the derivative of the specified order of a polynomial.

print numpy.polyder([1, 1, 1, 1])       #Output : [3 2 1]

polyval

The polyval tool evaluates the polynomial at specific value.

print numpy.polyval([1, -2, 0, 2], 4)   #Output : 34

polyfit

The polyfit tool fits a polynomial of a specified order to a set of data using a least-squares approach.

print numpy.polyfit([0,1,-1, 2, -2], [0,1,1, 4, 4], 2)
#Output : [  1.00000000e+00   0.00000000e+00  -3.97205465e-16]

The functions polyadd, polysub, polymul, and polydiv also handle proper addition,
subtraction, multiplication, and division of polynomial coefficients, respectively.

Task  

You are given the coefficients of a polynomial $\mbox{P}$. 

Your task is to find the value of $\mbox{P}$ at point $\boldsymbol{x}$.

Input Format

The first line contains the space separated value of the coefficients in $\mbox{P}$. 

The second line contains the value of $\boldsymbol{x}$.

Output Format

Print the desired value.

Sample Input
1.1 2 3
0

Sample Output
3.0

Source: hackerrank | Difficulty: EASY


Solutions:
import numpy
coeff = [float(x) for x in input().strip().split()]
print(numpy.polyval(coeff, float(input().strip())))


import numpy
equation = numpy.array(list(map(float, input().split())))
x = float(input())
print(numpy.polyval(equation, x))


import numpy
P = list(map(float, input().split()))
x = int(input().strip())
lenght = len(P)
sum = float(0)
for i in range(lenght):
	sum += P[i] * numpy.power(x, lenght - i - 1)
print(sum)


import numpy as np
arr = np.array(list(map(float, input().split())))
x = int(input())
print(np.polyval(arr, x))


import numpy as np
L = list(map(float, input().split()))
x = int(input())
print(np.polyval(L, x))


import numpy
print(numpy.polyval(list(map(float, input().strip().split())), float(input())))


import numpy
p = [float(e) for e in input().split()]
x = float(input())
print(numpy.polyval(p, x))


import numpy
p = list(map(float, input().split()))
x = int(input())
print(numpy.polyval(p, x))


import numpy as np
coef = list(map(float, input().split()))
x = float(input())
print(np.polyval(coef, x))


import numpy
print(numpy.polyval(list(map(float, input().strip().split())), float(input().strip())))


import numpy
A = list(map(float, input().split()))
A = numpy.array(A, float)
n = float(input())
print(numpy.polyval(A, n))


import numpy
a = numpy.array(list(map(float, input().split())))
x = int(input())
print(numpy.polyval(a, x))


import numpy
Ps = [float(x) for x in input().split()]
print(numpy.polyval(Ps, int(input())))


import numpy
print(numpy.polyval([float(x) for x in input().split()], int(input())))


import numpy
p = numpy.array(list(map(float, input().split())), float)
x = float(input())
print(numpy.polyval(p, x))


import numpy
a = numpy.array(input().split(), float)
x = int(input())
print(numpy.polyval(a, x))


import numpy
a = list(map(float, input().split()))
print(numpy.polyval(a, float(input())))


import numpy
a = numpy.array(input().split(), float)
print(numpy.polyval(a, int(input())))


import numpy
A = numpy.array(list(map(float, input().split())))
print(numpy.polyval(A, float(input())))


import numpy as np
p = list(map(float, input().split()))
x = int(input())
print(np.polyval(p, x))


import numpy as np
coeffs = list(map(float, input().split()))
x = float(input())
print(np.polyval(coeffs, x))


import numpy
coeff = numpy.array(input().split(), float)
x = int(input())
print(numpy.polyval(coeff, x))


import numpy
print(numpy.polyval([float(i) for i in input().split()], int(input())))


import numpy
p = numpy.array([x for x in input().split()], float)
print(numpy.polyval(p, float(input())))


import sys
import numpy as np
coeff = [float(y) for y in input().split()]
x = float(input())
print(np.polyval(coeff, x))


import numpy
print(numpy.polyval(tuple(map(float, input().split())), float(input())))


import numpy
p = list(map(float, input().split()))
print(numpy.polyval(p, float(input())))


import numpy as np
coeffs = [float(e) for e in input().split()]
x = float(input())
print(np.polyval(coeffs, x))


import numpy
P = [i for i in map(float, input().split())]
x = int(input())
print(numpy.polyval(P, x))


import numpy
import numpy
a = numpy.array(input().split(), float)
x = int(input())
print(numpy.polyval(a, x))


from numpy import polyval
P = tuple(map(float, input().strip().split()))
x = float(input())
print(polyval(P, x))


import numpy
p = list(map(float, input().split()))
x = float(input())
print(numpy.polyval(p, x))


import numpy
print(numpy.polyval(list(map(float, input().strip().split(' '))), int(input())))


import numpy
pol = list(map(float, input().split()))
x = float(input())
print(numpy.polyval(pol, x))


import numpy as np
P = np.array(list(map(lambda x: float(x), input().split())))
x = int(input())
print(np.polyval(P, x))


import numpy
p = list(map(float, input().strip().split()))
x = int(input())
print(numpy.polyval(p, x))


import numpy as np
p = list(map(float, input().split()))
print(np.polyval(p, float(input())))


import numpy
coeffs = list(map(float, input().split()))
x = float(input())
print(numpy.polyval(coeffs, x))


import numpy
print(numpy.polyval(numpy.array(input().split(), float), int(input())))


import numpy
print(numpy.polyval([float(x) for x in input().strip().split()], int(input().strip())))


import numpy
ps = list(map(float, input().split()))
x = float(input())
print(numpy.polyval(ps, x))


import numpy
coefs = list(map(float, input().split()))
x = float(input())
print(numpy.polyval(coefs, x))


import numpy
arr = numpy.array([a for a in input().split()], float)
x = int(input())
print(numpy.polyval(arr, x))


import numpy
p = tuple((float(i) for i in input().split()))
x = float(input())
print(numpy.polyval(p, x))


import numpy
eq = [float(x) for x in input().split()]
x = float(input())
print(numpy.polyval(eq, x))


import numpy
p = numpy.array(list(map(float, input().strip().split())))
x = int(input().strip())
print(numpy.polyval(p, x))


import numpy as np
data = np.array([float(i) for i in input().split()])
print(np.polyval(data, float(input())))


import numpy
P = [float(x) for x in input().split()]
x = float(input())
print(numpy.polyval(P, x))


import numpy
a = numpy.array(list(map(float, input().split())))
x = float(input())
print(numpy.polyval(a, x))


import numpy as np
arr = input().split()
num = float(input())
print(np.polyval(np.array(arr, dtype=float), num))


import numpy
a = numpy.array(input().split(), float)
print(numpy.polyval(a, float(input())))


import numpy as np
a = list(map(float, input().split()))
n = float(input())
print(np.polyval(a, n))


import numpy
a = numpy.array(input().split(' '), float)
print(numpy.polyval(a, int(input())))


import numpy
P = [float(i) for i in input().strip().split()]
x = float(input())
print(numpy.polyval(P, x))


import numpy as np

def main():
	l = np.array(input().split(), float)
	x = float(input())
	print(np.polyval(l, x))
main()


import numpy
P = list(map(float, input().split()))
x = int(input())
print(numpy.polyval(P, x))


import numpy as np
array = np.array(list(map(float, input().strip().split())))
x = float(input().strip())
print(np.polyval(array, x))


import operator
import numpy

def read_f(f):
	return f(input())

def read_f_words(f):
	return mapl(f, input().split())

def mapl(f, x):
	return list(map(f, list(x)))

def read_a(f, n):
	ns = []
	for x in range(n):
		ns.append(read_f_words(f))
	return numpy.array(ns, f)
coeffs = read_f_words(float)
x = read_f(float)
print(numpy.polyval(coeffs, x))


import numpy
print(numpy.polyval(list(map(float, input().split())), float(input())))


import numpy as np
pol = np.array([float(x) for x in input().split(' ')])
x = float(input())
print(np.polyval(pol, x))


import numpy
a = [float(e) for e in input().split()]
x = float(input())
print(numpy.polyval(a, x))


import numpy
arr = [float(x) for x in input().split()]
i = int(input())
print(numpy.polyval(numpy.array(arr), i))


import numpy
coeff = list(map(float, input().split()))
x = float(input())
f = 0
l = len(coeff)
for i in range(l):
	f = x ** (l - i - 1) * coeff[i] + f
print(f)


import sys
import numpy as np

def main():
	f = open(sys.argv[1], 'r') if len(sys.argv) > 1 else sys.stdin
	coef = [float(i) for i in f.readline().split()]
	pt = float(f.readline())
	print(np.polyval(coef, pt))
main()


import numpy as np
a = np.array(input().split(), float)
print(np.polyval(a, int(input())))


import numpy
p = list(map(float, input().split(' ')))
x = float(input())
print(numpy.polyval(p, x))


import numpy as np
n = list(map(float, input().split()))
point = float(input())
print(np.polyval(n, point))


import numpy as np
import sys
A = np.array(sys.stdin.readline().split(), float)
x = int(sys.stdin.readline())
print(np.polyval(A, x))


import numpy
coeff = numpy.array(list(map(float, input().split())))
val = float(input())
print(numpy.polyval(coeff, val))


import numpy as np
poly = list(map(float, input().split()))
x = int(input())
print(np.polyval(np.array(poly), x))


import numpy as np
print(np.polyval(list(map(float, input().split(' '))), float(input())))


import numpy
print(numpy.polyval([float(x) for x in input().split()], float(input())))


import numpy
mojir = input()
hyo = mojir.split(' ')
pomoto = [float(mono) for mono in hyo]
eks = float(input())
print(numpy.polyval(pomoto, eks))


import numpy
poly = numpy.array(input().split(), float)
val = float(input().strip())
print(numpy.polyval(poly, val))


import numpy as np
p = [float(x) for x in input().split()][::-1]
print(np.polynomial.polynomial.polyval(float(input()), p))


import numpy
lis = list(map(float, input().split()))
val = int(input())
print(numpy.polyval(lis, val))


import numpy
arr1 = list(map(float, input().split()))
print(numpy.polyval(arr1, int(input())))


import numpy as np
print(np.polyval(list(map(float, input().split())), float(input())))


import numpy as np
coef = list(map(float, input().split()))
res = float(input())
print(np.polyval(coef, res))


import numpy
P = numpy.array(list(map(float, input().split())))
x = float(input())
print(numpy.polyval(P, x))


import numpy
(P, x) = (numpy.array(input().split(), float), float(input()))
print(numpy.polyval(P, x))


import numpy
P = numpy.array(input().split(), float)
x = float(input())
print(numpy.polyval(P, x))


import numpy
m = list(map(float, input().split()))
p = float(input())
print(numpy.polyval(m, p))


import numpy
coeffs = list(map(float, input().strip().split()))
print(numpy.polyval(coeffs, int(input().strip())))


import numpy
poly = numpy.array(input().split(' '), float)
x = float(input())
print(numpy.polyval(poly, x))


import numpy
print(numpy.polyval(list(map(float, input().split())), int(input())))