1 2 3 |
eval(expression, globals=None, locals=None) |
Parameter
expression: This parameter represents a String, that will be evaluated as Python code globals: It is an optional parameter that represents a dictionary containing global parameters locals: It is also an optional parameter that represents a dictionary containing local parametersReturn
This function returns the result of the evaluated expression Example 1
1 2 3 4 5 6 |
# Python Program explaining # eval() function x = 'print(565)' eval(x) |
1 2 3 |
565 |
1 2 3 4 5 6 7 |
# Python Program explaining # eval() function x = 11 print(eval('x==11')) print(eval('x+2')) |
1 2 3 4 |
True 13 |