Input() Hackerrank solution python
In Python 2, the expression input() is equivalent to eval(raw _input(prompt)).
>>> input() 1+2 3 >>> company = 'HackerRank' >>> website = 'www.hackerrank.com' >>> input() 'The company name: '+company+' and website: '+website 'The company name: HackerRank and website: www.hackerrank.com'
You are given a polynomial P of a single indeterminate (or variable), x.
You are also given the values of x and k. Your task is to verify if P(x)=k.
All coefficients of polynomial P are integers.
x and y are also integers.
The first line contains the space separated values of x and k.
The second line contains the polynomial P.
True if P(x)=k. Otherwise, print
1 4 x**3 + x**2 + x + 1
Hence, the output is
#Input() Hackerrank solution python x,k=raw_input().split() x=int(x) P=raw_input() A=eval(P) if A==int(int(k)): print("True") else: print("False") #Input() Hackerrank solution python
Disclaimer: This problem is originally created and published by HackerRank, we only provide solutions to this problem. Hence, doesn’t guarantee the truthfulness of the problem. This is only for information purposes.