Input() in python HackerRank Solution

Hello coders, In this post, you will learn how to solve Input() in python HackerRank Solution. This problem is a part of the Python Hacker Rank series.

Input() in python HackerRank Solution
Input() in python HackerRank Solution

Input() in python HackerRank Solution


This challenge is only forPython 2.input()in Python 2, the expression input() is equivalent to eval(raw _input(prompt)).
code :

>>> input()
>>> company = 'HackerRank'
>>> website = ''
>>> input()
'The company name: '+company+' and website: '+website
'The company name: HackerRank and website:'

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 :


Explanation :

P(1) = 1^3 + 1^2 + 1 + 1 = 4 = k
Hence, the output is True.

Input() in python HackerRank Solution

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

Disclaimer: The above Problem (Input() in python) is generated by Hackerrank but the Solution is Provided by Chase2Learn. This tutorial is only for Educational and Learning purposes. Authority if any of the queries regarding this post or website fill the following contact form thank you.

Sharing Is Caring

Leave a Comment