Algorithm


Problem Name: Python - Input()

Problem Link: https://www.hackerrank.com/challenges/input/problem?isFullScreen=true

In this HackerRank Functions in PYTHON problem solution,

This challenge is only forPython 2.

 

input()

 

In Python 2, the expression input() is equivalent to eval(raw _input(prompt)).

 

Code

 

>>> 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'

 


 

Task

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.

Constraints
All coefficients of polynomial p are integers.

x and y are also integers.

Input Format

The first line contains the space separated values of x and k.

The second line contains the polynomial P.

Output Format

Print True if P(x) - k. Otherwise, print False.

Sample Input

1 4
x**3 + x**2 + x + 1

Sample Output

True

Explanation

P(1) = 1***3 + 1**2 + 1 + 1 = 4 = k

Hence, the output is True.

 

 

 

 

 

Code Examples

#1 Code Example with Python Programming

Code - Python Programming


if __name__ == "__main__":
    x, k = map(int, input().split())
    expr = input()

    print(eval(expr) == k)
Copy The Code & Try With Live Editor
Advertisements

Demonstration


Previous
[Solved] Zipped! in PYTHON solution in Hackerrank
Next
[Solved] Python Evaluation in PYTHON solution in Hackerrank