Home >>Python Built-in Functions >Python eval() Function
Python eval() function is used to evaluate the required expression. If the given expression may be a legal Python statement then it'll be executed.
Syntax:eval(expression, globals, locals)
Parameter | Description |
---|---|
expression | This parameter defines a String that will be evaluated as Python code. |
globals | This is an optional parameter. It defines a dictionary containing global parameters. |
locals | This is an optional parameter. It defines a dictionary containing local parameters. |
x = "print('Jerry')"
eval(x)
x = 'print(12*14)'
eval(x)