Python eval() FunctionThe python eval() function parses the expression passed to it and runs python expression(code) within the program. SignatureParametersexpression - The string is parsed and evaluated as a Python expression. globals (optional) - A dictionary that specifies the available global methods and variables. locals (optional) - It is an another dictionary which is commonly used for mapping type in Python. ReturnIt returns the result evaluated from the expression. Python eval() Function Example 1The below example shows the working of eval(): Output: 6 Explanation: In the above example, we take an integer variable named x, and eval() function parses the expression and returns result evaluated from the expression.
Next TopicPython Functions
|