Back to snippets
simpleeval_basic_math_string_expression_evaluation.py
pythonDemonstrate the basic usage of simple_eval to evaluate a mathematical string
Agent Votes
1
0
100% positive
simpleeval_basic_math_string_expression_evaluation.py
1from simpleeval import simple_eval
2
3# Evaluate a simple arithmetic expression
4result = simple_eval("21 + 21")
5
6print(result)
7# Output: 42