collection data types for key in sorted(users)user users[keyinitial "if user middlenameinitial user middlename[ name "{ surname}{ forename}{ }format(userinitialprint("{ <{nw}({ id: }{ username:{uw}}formatnameusernw=namewidthuw=usernamewidth)once all the records have been processedthe print_users(function is calledwith the users dictionary passed as its parameter str format( the first print(statement prints the column titlesand the second print(statement prints hyphens under each title this second statement' str format(call is slightly subtle the string we give to be printed is ""that isthe empty string--we get the hyphens by printing the empty string padded with hyphens to the given widths next we use for in loop to print the details of each userextracting the key for each user' dictionary item in sorted order for convenience we create the user variable so that we don' have to keep writing users[keythroughout the rest of the function in the loop' first call to str format(we set the name variable to the user' name in surnameforename (and optional initialform we access items in the user named tuple by name once we have the user' name as single string we print the user' detailsconstraining each column(nameidusernameto the widths we want the complete program (which differs from what we have reviewed only in that it has some initial comment lines and some importsis in generate_usernames py the program' structure--read in data fileprocess each recordwrite output--is one that is very frequently usedand we will meet it again in the next example statistics py |suppose we have bunch of data files containing numbers relating to some processing we have doneand we want to produce some basic statistics to give us some kind of overview of the data each file uses plain text (ascii encodingwith one or more numbers per line (whitespace-separatedhere is an example of the kind of output we want to producecount mean median mode [ std dev