Input() in python - HackerRank Solution

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


Problem :


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.



Solution :


1
2
3
4
5
6
7
8
# Input() in python - Hacker Rank Solution
# Python 3
# Enter your code here. Read input from STDIN. Print output to STDOUT
# Input() in python - Hacker Rank Solution START
storage = raw_input().split()
x = int(storage[0])
print input()==int(storage[1])
# Input() in python - Hacker Rank Solution END





Disclaimer :-
the above hole problem statement is given by hackerrank.com but the solution is generated by the codeworld19 authority if any of the query regarding this post or website fill the following contact form thank you.

Next Post Previous Post
3 Comments
  • irfan mohammed
    irfan mohammed Sunday, October 18, 2020

    This comment has been removed by the author.

    • irfan mohammed
      irfan mohammed Sunday, October 18, 2020

      oo

  • irfan mohammed
    irfan mohammed Sunday, October 18, 2020

    #python 3
    i blindly use testcase instead of logic
    n,k=map(int,input().split())
    x=input()
    if (k==15 and n==2) and x[9]=="-":
    print("False")
    else:
    print("True")

Add Comment
comment url