Header Ad

HackerRank Input() problem solution in python

In this Input() problem we need to develop a python program that can read an integer input separated with space and then we need to verify the function using input values.

HackerRank Input() solution in python


Problem solution in Python 2 programming.

# Enter your code here. Read input from STDIN. Print output to STDOUT

x,k = map(int,raw_input().split())
print k==input()


Problem solution in Python 3 programming.

# Enter your code here. Read input from STDIN. Print output to STDOUT
ui = input().split()
x = int(ui[0])
print(eval(input()) == int(ui[1]))


Problem solution in pypy programming.

x,k=map(int,raw_input().strip().split(" "))
p=eval(raw_input())
if(p==k):
    print True
else:
    print False


Problem solution in pypy3 programming.

s = input() # read input
# s = "1 4";
f = input()
# f = "x^3 + x^2 + x + 1"
(x,y) = s.split() # args
x=int(x)
y=int(y)
# print (x, y)
z=eval(f)
if (z == y):
    print ("True")
else:
    print ("False")


Post a Comment

0 Comments