variable scope it is important to understand the scoping rules of variables inside functions each time function executesa new local namespace is created this represents local environment that contains the names of the parameters and variables that are assigned by the function to resolve namespace when function is calledthe python interpreter first searches the local namespace (that isthe function itselfand if no match is foundit searches the global namespace this global namespace is the module in which the function was defined if the name is still not foundit searches the built-in namespace finallyif this fails then the interpreter raises nameerror exception consider the following codea= = def my_function()global = = my_function(print( #prints print( #prints here is the output of the preceding codein the preceding codewe define two global variables we need to tell the interpreterusing the keyword globalthat inside the functionwe are referring to global variable when we change this variable to these changes are reflected in the global scope howeverthe variable we set to is local to the functionand any changes made to it inside the function are not reflected in the global scope when we run the function and print bwe see that it retains its global value flow control and iteration python programs consist of sequence of statements the interpreter executes each statement in order until there are no more statements this is true if both files run as the main program as well as files that are loaded via import all statementsincluding variable assignmentfunction definitionsclass definitionsand module importshave equal status there are no special statements that have higher priority than any other and every statement can be placed anywhere in program there are two main ways of controlling the flow of program executionconditional statements and loops