Header Ad

HackerRank Python Evaluation problem solution

In this Python evaluation problem, You are given an expression in a line. Read that line as a string variable, such as var, and print the result using eval(var).

HackerRank Python Evaluation solution


Problem solution in Python 2 programming.

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

s=raw_input()
eval(s)


Problem solution in Python 3 programming.

var = input()
eval(var)


Problem solution in pypy programming.

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

input()
# or:
# eval(raw_input())


Problem solution in pypy3 programming.

var=input()
eval(var)


Post a Comment

0 Comments