appendix user-defined modules iomod py module containing the routines used to extract and print grades def extractgrades()gradelist list(grade intinput("enter the first grade"while grade > gradelist appendgrade grade intinput("enter the next grade (or to quit)"return gradelist def printreportthelistavggrade )print"the average grade for the "len(thelist)"grades entered is"avggrade compmod py module which defines function for computing the average grade def computeaveragethelist )total for grade in thelist total +grade return total len(thelistto execute the programyou would enter the commandpython grades py at the command-line prompt since the driver program is the main file containing the starting point of execution the python interpreter will include each module specified within an import statement in this examplethat includes both iomod py and compmod py as indicated at the top of grades py the interpreter will only import module onceeven if it is encountered multiple times thusyou should always import module within source file if any component of that module is needed let the interpreter worry about omitting the module if it has already been included namespaces all identifiers in python live within namespacethe context in which identifiers are defined you can think of namespace as container or index in which various identifiers are stored when an identifier is referenced in python programa search is performed in particular namespace to determine if that identifier is valid the namespace concept allows programmers to create duplicate nameseach existing in different namespace in pythoneach module constitutes its own namespace any identifier defined within module may be freely used within that same module but what about identifiers defined within other modulesit depends how they are imported when the plain import statement is usedimport math math sqrtx