Python Interviews: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 79:
>>> hash(tuple(a))
1409902629973635913
 
*Eval Function:
 
You are given a polynomial of a single indeterminate (or variable), .
You are also given the values of and . Your task is to verify if .
 
Input:
1 4
x**3 + x**2 + x + 1
 
<pre>
a = (input()).split()
x = int(a[0])
k = int(a[1])
 
# Sol 1:
print eval(input()) == k
 
# Python 2:
print eval(raw_input()) == k
 
 
# Sol 2:
f = lambda x:eval(input())
print (f(x) == k)
</pre>