and no other this rule means thatnames assigned inside def can only be seen by the code within that def you cannot even refer to such names from outside the function names assigned inside def do not clash with variables outside the defeven if the same names are used elsewhere name assigned outside given def ( in different def or at the top level of module fileis completely different variable from name assigned inside that def in all casesthe scope of variable (where it can be usedis always determined by where it is assigned in your source code and has nothing to do with which functions call which in factas we'll learn in this variables may be assigned in three different placescorresponding to three different scopesif variable is assigned inside defit is local to that function if variable is assigned in an enclosing defit is nonlocal to nested functions if variable is assigned outside all defsit is global to the entire file we call this lexical scoping because variable scopes are determined entirely by the locations of the variables in the source code of your program filesnot by function calls for examplein the following module filethe assignment creates global variable named (visible everywhere in this file)but the assignment creates local variable (visible only within the def statement) global (modulescope def func() local (functionscope xa different variable even though both variables are named xtheir scopes make them different the net effect is that function scopes help to avoid name clashes in your programs and help to make functions more self-contained program units--their code need not be concerned with names used elsewhere scope details before we started writing functionsall the code we wrote was at the top level of module ( not nested in def)so the names we used either lived in the module itself or were built-ins predefined by python ( opentechnicallythe interactive prompt is module named __main__ that prints results and doesn' save its codein all other waysthoughit' like the top level of module file functionsthoughprovide nested namespaces (scopesthat localize the names they usesuch that names inside function won' clash with those outside it (in module or another functionfunctions define local scope and modules define global scope with the following properties scopes