The Exec () function supports the dynamic Python code and takes large code blocks, unlike Eval (). The transmitted functions of the code should be either a line or an object of code, for example, generated by the Compile () function. If this is a line, the line is analyzed as a set of Python operators, which is then performed (if a syntactic error does not occur). If this is an object of code, it is simply performed. In all cases, it is expected that the executable code will be valid, like entering a file.
In all cases, if Globals and Locals are lowered, the code is executed in the current area of visibility. If global variables are indicated, it should be a dictionary (and not a subclass of a dictionary), which will be used for both global and local variables. If local variables are transmitted, then Locals can be any displaying object.
In this example, 120 should have been printed as a conclusion, but instead the message “There is no conclusion” is displayed and an exception arises. Despite the fact that we imported a mathematical module, the Factorial () method did not work due to the restrictions that we installed by conveying the global parameter.
We can also allow the implementation of some of the many functions. Suppose we want all other mathematical modules to be limited, except for the Factorial () function.
#machinelearning #artificialintelligence #ai #datascience #programming #Technology #Deeplearning