Python exe() function

Facebooktwitterredditpinterestlinkedinmailby feather

Python exe() function

The exec() function in Python executes the specified Python code and accepts large blocks of code. It supports dynamic execution of Python code where the object must be either a string or a code object.

Syntax:

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 parameters

Return

This function returns the result of the evaluated expression

Example 1

Output

Example 2

Output

Facebooktwitterredditpinterestlinkedinmailby feather