Write a program that accepts basic mathematic expressions from the console and prints the evaluation result

Question:

Write a program that accepts basic mathematic expressions from the console and prints the evaluation result.

Example:

If the following string is given as input to the program: 35+3

Then, the output of the program should be: 38

Hints:

  • Use eval() to evaluate an expression.

Solution:

expression = raw_input()
print eval(expression)

Leave a Comment