functions and branching local variables are foundas for and in this casethese values are used if some variables are not found in the local namespacepython will move to the global namespaceand look for global variables that match the given names if variable with the right name is found among the global variablesthat isit has been defined in the main programthen the corresponding value is used if no global variable with the right name is found there are no more places to searchand the program ends with an error message this sequential search for variables is quite natural and logicalbut still potential source of confusion and programming errors additional confusion can arise if we attempt to change global variable inside function considerfor instancethis small extension of the code abovep def amount( ) return *( + / )** print(amount( = )print( as revealed by the print statementsr is set to inside the functionbut the global variable remains unchanged after the function has been called since the line occurs inside functionpython will treat this as the definition of new local variablerather than trying to change global one we thus define new local with value while there is still another defined in the global namespace after the function has endedthe local variable no longer exists (in programming termsit goes out of scope)whereas the global is still there and has its original value if we actually want to change global variable inside functionwe must explicitly state so by using the keyword global consider this minor change of the code abovep def amount( )global return *( + / )** print(amount( = )print(