id
int64
0
25.6k
text
stringlengths
0
4.59k
8,600
rapid introduction to procedural programming numbers[ count sum lowest highest mean it will take about four lines to initialize the necessary variables (an empty list is simply [])and less than lines for the while loopincluding basic error handling printing out at the end can be done in just few linesso the whole progr...
8,601
methodbut we haven' covered that yetso we won' use it here extend the averages program with block of code that sorts the list of numbers--efficiency is of no concernjust use the easiest approach you can think of once the list is sortedthe median is the middle value if the list has an odd number of itemsor the average o...
8,602
identifiers and keywords integral types floating-point types strings |||data types in this we begin to take much more detailed look at the python language we start with discussion of the rules governing the names we give to object referencesand provide list of python' keywords then we look at all of python' most import...
8,603
data types sensitiveso for exampletaxratetaxratetaxratetaxrateand taxrate are five different identifiers the precise set of characters that are permitted for the start and continuation are described in the documentation (python language referencelexical analysisidentifiers and keywords section)and in pep (supporting no...
8,604
there are about names in the listso we have omitted most of them those that begin with capital letter are the names of python' built-in exceptionsthe rest are function and data type names the second convention concerns the use of underscores (_names that begin and end with two underscores (such as __lt__should not be u...
8,605
data types the easiest way to check whether something is valid identifier is to try to assign to it in an interactive python interpreter or in idle' python shell window here are some examplesstretch-factor syntaxerrorcan' assign to operator miles syntaxerrorinvalid syntax str legal but bad 'impot syntaxerroreol while s...
8,606
table numeric operators and functions tuples syntax description adds number and number subtracts from multiplies by divides by yalways produces float (or complex if or is complexx / divides by ytruncates any fractional part so always produces an int resultsee also the round(function produces the modulus (remainderof di...
8,607
data types integer literals are written using base (decimalby defaultbut other number bases can be used when this is convenient xdecade decimal binary octal hexadecimal binary numbers are written with leading boctal numbers with leading oand hexadecimal numbers with leading uppercase letters can also be used all the us...
8,608
the original object is created (shallow copying is covered in if an argument of different type is givena conversion is attempted this use is shown for the int type in table if the argument is of type that supports conversions to the given type and the conversion failsa valueerror exception is raisedotherwisethe resulta...
8,609
data types booleans |there are two built-in boolean objectstrue and false like all other python data types (whether built-inlibraryor custom)the bool data type can be called as function--with no arguments it returns falsewith bool argument it returns copy of the argumentand with any other argument it attempts to conver...
8,610
the inexactness is not problem specific to python--all programming languages have this problem with floating-point numbers python produces much more sensible-looking output - - ( - when python outputs floating-point numberin most cases it uses david gay' algorithm this outputs the fewest possible digits without losing ...
8,611
data types table the math module' functions and constants # tuples syntax description math acos(xreturns the arc cosine of in radians math acosh(xreturns the arc hyperbolic cosine of in radians math asin(xreturns the arc sine of in radians math asinh(xreturns the arc hyperbolic sine of in radians math atan(xreturns the...
8,612
table the math module' functions and constants # syntax description math pi the constant papproximately math pow(xyreturns xy as float math radians(dconverts float from degrees to radians math sin(xreturns the sine of in radians math sinh(xreturns the hyperbolic sine of in radians math sqrt(xreturns math tan(xreturns t...
8,613
data types float fromhex(st hex(float = str =' + the exponent is indicated using ("power"rather than since is valid hexadecimal digit in addition to the built-in floating-point functionalitythe math module provides many more functions that operate on floatsas shown in tables and here are some code snippets that show ho...
8,614
have methodconjugate()which changes the sign of the imaginary part for examplez conjugate(( - conjugate(( + jnotice that here we have called method on literal complex number in generalpython allows us to call methods or access attributes on any literalas long as the literal' data type provides the called method or the ...
8,615
data types decimal decimal(" " decimal(' 'decimal numbers are created using the decimal decimal(function this function can take an integer or string argument--but not floatsince floats are held inexactly whereas decimals are represented exactly if string is used it can use simple decimal notation or exponential notatio...
8,616
decimal decimal( decimal decimal(" "decimal(' 'although the division using decimal decimals is more accurate than the one involving floatsin this case (on -bit machinethe difference only shows up in the fifteenth decimal place in many situations this is insignificant--for examplein this bookall the examples that need f...
8,617
data types table python' string escapes escape meaning \newline escape ( ignorethe newline \backslash (\\single quote ('\double quote ("\ ascii bell (bel\ ascii backspace (bs\ ascii formfeed (ff\ ascii linefeed (lf\ {nameunicode character with the given name \ooo character with the given octal value \ ascii carriage re...
8,618
the solution is to use raw strings these are quoted or triple quoted strings whose first quote is preceded by the letter inside such strings all characters are taken to be literalsso no escaping is necessary here is the phone regular expression using raw stringphone re compile( "^((?:[(]\ +[)])?\ *\ +(?:-\ +)?)$"if we ...
8,619
data types "anarchists are chr( chr( 'anarchists are ascii( "'anarchists are \ \ 'if we enter on its own in idleit is output in its string formwhich for strings means the characters are output enclosed in quotes if we want only ascii characterswe can use the built-in ascii(function which returns the representational fo...
8,620
points which gives ascii sorting for english loweror uppercasing all the strings compared produces more natural english language ordering normalizing is unlikely to be needed unless the strings are from external sources like files or network socketsbut even in these cases it probably shouldn' be done unless there is ev...
8,621
data types offers better solution the method takes sequence as an argument ( list or tuple of strings)and joins them together into single string with the string the method was called on between each one for exampletreatises ["arithmetica""conics""elements"join(treatises'arithmetica conics elements"--join(treatises'arit...
8,622
table string methods # syntax description capitalize(returns copy of str with the first letter capitalizedsee also the str title(method returns copy of centered in string of length width padded with spaces or optionally with char ( string of length )see str ljust()str rjust()and str format( center(widthchars count(tsta...
8,623
data types table string methods # syntax description isnumeric(returns true if is nonempty and every character in is numeric unicode character such as digit or fraction isprintable(returns true if is empty or if every character in is considered to be printableincluding spacebut not newline isspace(returns true if is no...
8,624
table string methods # syntax description strip(charsreturns copy of with leading and trailing whitespace (or the characters in str charsremovedstr lstrip(strips only at the startand str rstrip(strips only at the end swapcase(returns copy of with uppercase characters lowercased and lowercase characters uppercasedsee al...
8,625
data types count(" " = [ :count(" " count(" " - = [ :- count(" "as we can seethe string methods that accept start and end indexes operate on the slice of the string specified by those indexes now we will look at another equivalencethis time to help clarify the behavior of str partition()--although we'll actually use st...
8,626
"\ no parking lstrip() rstrip() strip(('no parking ''\ no parking''no parking'"strip("[](){}"'unbracketedwe can also replace strings within strings using the str replace(method this method takes two string argumentsand returns copy of the string it is called on with every occurrence of the first string replaced with th...
8,627
data types both arguments must be the same length the str translate(method takes translation table as an argument and returns copy of its string with the characters translated according to the translation table here is how we could translate strings that might contain bengali digits to english digitstable "maketrans("\...
8,628
the str format(method returns new string with the replacement fields in its string replaced with its arguments suitably formatted for example"the novel '{ }was published in { }format("hard times" "the novel 'hard timeswas published in each replacement field is identified by field name in braces if the field name is sim...
8,629
data types when we take detailed look at format specifications we will now study each part of the replacement field in turnstarting with field names field names field name can be either an integer corresponding to one of the str format(method' argumentsor the name of one of the method' keyword arguments we discuss keyw...
8,630
so in summarythe field name syntax allows us to refer to positional and keyword arguments that are passed to the str format(method if the arguments are collection data types like lists or dictionariesor have attributeswe can access the part we want using [or notation this is illustrated in figure positional argument in...
8,631
data types the syntax may seem weird enough to make perl programmer feel at homebut don' worry--it is explained in all that matters for now is that we can use variable names in format strings and leave python to fill in their values simply by unpacking the dictionary returned by locals()--or some other dictionary--into...
8,632
and to force representational form but only using ascii characters here is an example"{ { ! { ! { ! }format(decimal decimal(" ")" decimal(' 'decimal(' ')in this casedecimal decimal' string form produces the same string as the string it provides for str format(which is what commonly happens alsoin this particular exampl...
8,633
data types fill align sign width precision type any character except left right center pad between sign and digits for numbers -pad numbers minimum field width force signsign if neededspace or as appropriate prefix ints with oor use commas for grouping maximum field width for stringsnumber of decimal places for floatin...
8,634
for integersthe format specification allows us to control the fill characterthe alignment within the fieldthe signwhether to use nonlocale-aware comma separator to group digits (from python )the minimum field widthand the number base an integer format specification begins with colonafter which we can have an optional p...
8,635
data types here are some examples that show the effects of the sign characters"[{ }[{ }]format( - space or sign ' [- ]"[{ :+}[{ :+}]format( - force sign '[+ [- ]"[{ :-}[{ :-}]format( - sign if needed '[ [- ]and here are two examples that use some of the type characters"{ : { : { : { : }format( ' deface deface"{ :# { :#...
8,636
passing an empty string as the locale tells python to try to automatically determine the user' locale ( by examining the lang environment variable)with fallback of the locale here are some examples that show the effects of different locales on an integer and floating-point numberxy ( locale setlocale(locale lc_all" " "...
8,637
data types the third example builds on the previous twoand adds the sign character to force the output of the sign in python decimal decimal numbers are treated by str format(as strings rather than as numbers this makes it quite tricky to get nicely formatted output from python decimal decimal numbers can be formatted ...
8,638
realistic context the example also uses some of the string methods we saw in the previous sectionand introduces function from the unicodedata module the program has just lines of executable code it imports two modulessys and unicodedataand defines one custom functionprint_unicode_table(we'll begin by looking at sample ...
8,639
data types after the imports and the creation of the print_unicode_table(functionexecution reaches the code shown here we begin by assuming that the user has not given word to match on the command line if command-line argument is given and is - or --helpwe print the program' usage information and set word to as flag to...
8,640
unicode code point available--this will vary depending on whether python was compiled to use the ucs- or the ucs- character encoding inside the while loop we get the unicode character that corresponds to the code point using the chr(function the unicodedata name(function returns the unicode character name for the given...
8,641
data types ingso unlike other encodingsunicode can handle characters from mixture of languagesrather than just one but how is unicode storedcurrentlyslightly more than unicode characters are definedso even using signed numbersa -bit integer is more than adequate to store any unicode code point so the simplest way to st...
8,642
artist "tage asenartist encode("latin " 'tage \xc \xe nartist encode("cp " 'tage \ fs\ nartist encode("utf " 'tage \xc \ \xc \xa nartist encode("utf " '\xff\xfet\ \ \ \ \ \xc \ \ \xe \ \ before an opening quote signifies bytes literal rather than string literal as conveniencewhen creating bytes literals we can use mixt...
8,643
data types print( "tage \xc \xe ndecode("latin ")tage asen the differences between the -bit latin- cp (an ibm pc encoding)and utf- encodings make it clear that guessing encodings is not likely to be successful strategy fortunatelyutf- is becoming the de facto standard for plain text filesso later generations may not ev...
8,644
- + - ac the ac part of the formula is called the discriminant--if it is positive there are two real rootsif it is zero there is one real rootand if it is negative there are two complex roots we will write program that accepts the aband factors from the user (with the and factors allowed to be )and then calculates and ...
8,645
data types except valueerror as errprint(errreturn this function will loop until the user enters valid floating-point number (such as - )and will accept only if allow_zero is true once the get_float(function is definedthe rest of the code is executed we'll look at it in three partsstarting with the user interactionprin...
8,646
using str format(with mapping unpacking more robust alternative to using positional arguments with their index positions as field namesis to use the dictionary returned by locals() technique we saw earlier in the equation ("{ } \ {superscript two{ } { \ {rightwards arrowx { }"format(**locals()and if we are using python...
8,647
data types "argentina", , , , , "bahamasthe", , , , , "bahrain", , , , , assuming the sample data is in the file data/co -sample csvand given the command csv html py co -sample htmlthe file co -sample html will have contents similar to thiscountry argentina we've tidied the output slightly and omitted some lines where ...
8,648
been defined the order in which the functions appear in the file ( the order in which they are createddoes not matter in the csv html py programthe first function we call is main(which in turn calls print_start(and then print_line(and print_line(calls extract_ fields(and escape_html(the program structure we have used i...
8,649
data types print_line(linecolormaxwidthcount + except eoferrorbreak print_end(the maxwidth variable is used to constrain the number of characters in cell--if field is bigger than this we will truncate it and signify this by adding an ellipsis to the truncated text we'll look at the print_start()print_line()and print_en...
8,650
we cannot use str split(","to split each line into fields because commas can occur inside quoted strings so we have farmed this work out to the extract_fields(function once we have list of the fields (as stringswith no surrounding quotes)we iterate over themcreating table cell for each one if field is emptywe output an...
8,651
data types def escape_html(text)text text replace("&""&amp;"text text replace("<""&lt;"text text replace(">""&gt;"return text this function straightforwardly replaces each special html character with the appropriate html entity we must of course replace ampersands firstalthough the order doesn' matter for the angle bra...
8,652
these numbers default to having decimal places of accuracybut this can be increased or decreased to suit our needs all three floating-point types can be used with the appropriate built-in mathematical operators and functions and in additionthe math module provides variety of trigonometrichyperbolicand logarithmic funct...
8,653
data types into sequence of bytes using particular encoding using the str encode(methodand we can convert sequence of bytes that use particular encoding back to string using the bytes decode(method the wide variety of character encodings currently in use can be very inconvenientbut utf- is fast becoming the de facto st...
8,654
if the user has typed "-hor "--helpon the command linea usage message should be output and (nonenonereturned (in this case main(should do nothing otherwisethe function should read any command-line arguments that are given and perform the appropriate assignments for examplesetting maxwidth if "maxwidth=nis givenand simi...
8,655
sequence types set types mapping types iterating and copying collections collection data types |||in the preceding we learned about python' most important fundamental data types in this we will extend our programming options by learning how to gather data items together using python' collection data types we will cover...
8,656
collection data types separately in some other sequence types are provided in the standard librarymost notablycollections namedtuple when iteratedall of these sequences provide their items in order strings we covered strings in the preceding in this section we will cover tuplesnamed tuplesand lists |tuples string slici...
8,657
immutable--behind the scenes python creates new tuple to hold the result and sets the left-hand object reference to refer to itthe same technique is used when these operators are applied to strings tuples can be compared using the standard comparison operators (=>)with the comparisons being applied item by item (and re...
8,658
collection data types there is no obligation to follow this coding stylesome programmers prefer to always use parentheses--which is the same as the tuple representational formwhereas others use them only if they are strictly necessary eyes ("brown""hazel""amber""green""blue""gray"colors (haireyescolors[ ][ :- ('green''...
8,659
strictly speakingthe parentheses are not needed on the rightbut as we noted earlierthe coding style used in this book is to omit parentheses for left-hand operands of binary operators and right-hand operands of unary statementsbut to use parentheses in all other cases we have already seen examples of sequence unpacking...
8,660
collection data types total for sale in salestotal +sale quantity sale price print("total ${ }format(total)printstotal $ the clarity and convenience that named tuples provide are often useful for examplehere is the "aircraftexample from the previous subsection ( done the nice wayaircraft collections namedtuple("aircraf...
8,661
responding value we have used mapping unpacking to convert the mapping into key-value arguments for the str format(method although named tuples can be very convenientin we introduce object-oriented programmingand there we will go beyond simple named tuples and learn how to create custom data types that hold data items ...
8,662
collection data types [ ][ = [ ][- = [- ][ = [- ][- ='echol[ ][ ][ = [ ][ ][- = [- ][- ][ = [- ][- ][- ='clists can be nestediterated overand slicedthe same as tuples in factall the tuple examples presented in the preceding subsection would work exactly the same if we used lists instead of tuples lists support membersh...
8,663
table list methods syntax description append(xappends item to the end of list count(xreturns the number of times item occurs in list extend(ml + appends all of iterable ' items to the end of list lthe operator +does the same thing index(xstartendreturns the index position of the leftmost occurrence of item in list (or ...
8,664
collection data types deleting items using the del statement although the name of the del statement is reminiscent of the word deleteit does not necessarily delete any data when applied to an object reference that refers to data item that is not collectionthe del statement unbinds the object reference from the data ite...
8,665
in either case the result is the list ['cedar''yew''fir''kauri''larch'individual items can be added at the end of list using list append(items can be inserted at any index position within the list using list insert()or by assigning to slice of length for examplegiven the list woods ["cedar""yew""fir""spruce"]we can ins...
8,666
collection data types stridingfor examplex[:: but this will give us the items at index positions and so on we can fix this by giving an initial starting indexso now we have [ :: ]and this gives us slice of the items we want to set each item in the slice to we need list of sand this list must have exactly the same numbe...
8,667
if (year = and year ! or (year = )leaps append(yearwhen the built-in range(function is given two integer argumentsn and mthe iterator it returns produces the integers nn of courseif we knew the exact range beforehand we could use list literalfor exampleleaps [ list comprehension is an expression and loop with an option...
8,668
collection data types using list comprehension in this case reduced the code from four lines to two-- small savingsbut one that can add up quite lot in large projects since list comprehensions produce liststhat isiterablesand since the syntax for list comprehensions requires an iterableit is possible to nest list compr...
8,669
only hashable objects may be added to set hashable objects are objects which have __hash__(special method whose return value is always the same throughout the object' lifetimeand which can be compared for equality using the __eq__(special method (special methods--methods whose name begins and ends with two underscores-...
8,670
table set methods and operators syntax description add(xadds item to set if it is not already in clear(removes all the items from set copy(returns shallow copy of set difference(ts returns new set that has every item that is in set that is not in set removes every item that is in set from set difference_update(ts - dis...
8,671
collection data types processingonce for each unique address assuming that the ip addresses are hashable and are in iterable ipsand that the function we want called for each one is called process_ip(and is already definedthe following code snippets will do what we wantalthough with subtly different behaviorseen set(for...
8,672
set comprehensions in addition to creating sets by calling set()or by using set literalwe can also create sets using set comprehensions set comprehension is an expression and loop with an optional condition enclosed in braces like list comprehensionstwo syntaxes are supported{expression for item in iterable{expression ...
8,673
collection data types another consequence of the immutability of frozen sets is that they meet the hashable criterion for set itemsso sets and frozen sets can contain frozen sets we will see more examples of set use in the next sectionand also in the examples section mapping types || mapping type is one that supports t...
8,674
the dict data type can be called as functiondict()--with no arguments it returns an empty dictionaryand with mapping argument it returns dictionary based on the argumentfor examplereturning shallow copy if the argument is dictionary it is also possible to use sequence argumentproviding that each item in the sequence is...
8,675
collection data types ( 'mars 'rover'venus - 'blue[ ' ' 'root none figure dictionary is an unsorted collection of (keyvalueitems with unique keys key items can also be removed (and returnedfrom the dictionary using the dict pop(method dictionaries support the built-in len(functionand for their keysfast membership testi...
8,676
table dictionary methods syntax description clear(removes all items from dict copy(returns shallow copy of dict fromkeyssvreturns dict whose keys are the items in sequence and whose values are none or if is given shallow and deep copying get(kreturns key ' associated valueor none if isn' in dict get(kvreturns key ' ass...
8,677
collection data types difference symmetric difference we can use the membership operatorinto see whether particular key is in dictionaryfor examplex in and we can use the intersection operator to see which keys from given set are in dictionary for exampled {fromkeys("abcd" set("acx"matches keys( ={' ' ' ' ' ' ' ' ={' '...
8,678
reading and writing text files files are opened using the built-in open(functionwhich returns "file object(of type io textiowrapper for text filesthe open(function takes one mandatory argument--the filenamewhich may include path--and up to six optional argumentstwo of which we briefly cover here the second argument is ...
8,679
collection data types subtler approach we call dict get(with default value of if the word is already in the dictionarydict get(will return the associated numberand this value plus will be set as the item' new value if the word is not in the dictionarydict get(will return the supplied default of and this value plus ( wi...
8,680
we begin by creating an empty dictionary then we iterate over each file listed on the command line and each line within each file we must account for the fact that each line may refer to any number of web siteswhich is why we keep calling str find(until it fails if we find the string "(our starting index positionby the...
8,681
using str format(with mapping unpacking collection data types although dictionary of web sites is likely to contain lot of itemsmany other dictionaries have only few items for small dictionarieswe can print their contents using their keys as field names and using mapping unpacking to convert the dictionary' key-value i...
8,682
inverted_d {vk for kv in items()the resultant dictionary can be inverted back to the original dictionary if all the original dictionary' values are unique--but the inversion will fail with typeerror being raised if any value is not hashable just like list and set comprehensionsthe iterable in dictionary comprehension c...
8,683
collection data types when default dictionary is createdwe can pass in factory function factory function is function thatwhen calledreturns an object of particular type all of python' built-in data types can be used as factory functionsfor exampledata type str can be called as str()--and with no argument it returns an ...
8,684
dict similar effect occurs with the use of the update(method for these reasonspassing keyword arguments or an unordered dict when creating an ordered dictionary or using update(on one is best avoided howeverif we pass list or tuple of key-value -tuples when creating an ordered dictionarythe ordering is preserved (since...
8,685
collection data types been created (an implementation of real sorted dictionary that automatically maintains its keys in sorted order is presented in iterating and copying collections ||once we have collections of data itemsit is natural to want to iterate over all the items they contain in this section' first subsecti...
8,686
product for in [ ]product * print(productprints product iter([ ]while truetryproduct *next(iexcept stopiterationbreak print(productprints any (finiteiterableican be converted into tuple by calling tuple( )or can be converted into list by calling list(ithe all(and any(functions can be used on iterators and are often use...
8,687
collection data types table common iterable operators and functions syntax description returns sequence that is the concatenation of sequences and returns sequence that is int concatenations of sequence in all(ireturns true if item is in iterable iuse not in to reverse the test returns true if every item in iterable ev...
8,688
print("{ }:{ }:{ }format(filenamelinoline rstrip())we begin by checking that there are at least two command-line arguments if there are notwe print usage message and terminate the program the sys exit(function performs an immediate clean terminationclosing any open files it accepts an optional int argument which is pas...
8,689
collection data types calculate( ( calculate(*tcalculate(*range( )in all three callsfour arguments are passed the second call unpacks -tupleand the third call unpacks the iterator returned by the range(function we will now look at small but complete program to consolidate some of the things we have covered so farand fo...
8,690
reading and writing text files sidebar having retrieved the two lists we open the output file for writingand keep the file object in variable fh ("file handle"we then loop timesand in each iteration we create line to be written to the fileremembering to include newline at the end of every line we make no use of the loo...
8,691
collection data types many items it is to produce-- number that cannot be less than the number of items the iterable can return the random sample(function returns an iterator that will produce up to the specified number of items from the iterable it is given--with no repeats so this version of the program will always p...
8,692
notice that since python functions are objects like any otherthey can be passed as arguments to other functionsand stored in collections without formality recall that function' name is an object reference to the functionit is the parentheses that follow the name that tell python to call the function when key function i...
8,693
collection data types python has sorted the list of tuples by comparing the first item of each tupleand when these are the sameby comparing the second item this gives sort order based on the integerswith the strings being tiebreakers we can force the sort to be based on the strings and use the integers as tiebreakers b...
8,694
when we assign large collectionssuch as long liststhe savings are very apparent here is an examplesongs ["because""boys""carol"beatles songs beatlessongs (['because''boys''carol']['because''boys''carol']herea new object reference (beatleshas been createdand both object references refer to the same list--no copying has ...
8,695
collection data types data types like numbers and strings this has the same effect as copying (except that it is more efficient)but for mutable data types such as nested collections this means that the objects they refer to are referred to both by the original collection and by the copied collection the following snipp...
8,696
the first program is about seventy lines long and involves text processing the second program is around ninety lines long and is mathematical in flavor between themthe programs make use of dictionarieslistsnamed tuplesand setsand both make great use of the str format(method from the preceding generate_usernames py |ima...
8,697
collection data types the program' overall logic is captured in the main(functiondef main()if len(sys argv= or sys argv[ in {"- ""--help"}print("usage{ file [file filen]]formatsys argv[ ])sys exit(usernames set(users {for filename in sys argv[ :]for line in open(filenameencoding="utf ")line line rstrip(if lineuser proc...
8,698
tuple type which we then return to the caller (main())which inserts the user into the users dictionaryready for printing if we had not created suitable constants to hold the index positionswe would be reduced to using numeric indexesfor exampleuser user(usernamefields[ ]fields[ ]fields[ ]fields[ ]although this is certa...
8,699
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 ...