collection data types count { : mean {mean:{fmt}median {median:{fmt}{ }std dev {std_dev:{fmt}}""formatcountmodelinefmt=real**statistics _asdict())str format( named tuple using str format(with mapping unpacking most of this function is concerned with formatting the modes list into the modeline string if there are no modesthe mode line is not printed at all if there is one modethe mode list has just one item (mode[ ]which is printed using the same format as is used for the other statistics if there are several modeswe print them as list with each one formatted appropriately this is done by using list comprehension to produce list of mode stringsand then joining all the strings in the list together with "in between each one the printing at the end is easy thanks to our use of named tuple and its _asdict(methodin conjunction with mapping unpacking this lets us access the statistics in the statistics object using names rather than numeric indexesand thanks to python' triple-quoted strings we can lay out the text to be printed in an understandable way recall that if we use mapping unpacking to pass arguments to the str format(methodit may be done only once and only at the end there is one subtle point to note the modes are printed as format item { }which is followed by backslash the backslash escapes the newlineso if the mode is the empty string no blank line will appear and it is because we have escaped the newline that we must put \ at the end of the modeline string if it is not empty summary ||in this we covered all of python' built-in collection typesand also couple of collection types from the standard library we covered the collection sequence typestuplecollections namedtupleand listwhich support the same slicing and striding syntax as strings the use of the sequence unpacking operator (*was also coveredand brief mention was made of starred arguments in function calls we also covered the set typesset and frozensetand the mapping typesdict and collections defaultdict we saw how to use the named tuples provided by python' standard library to create simple custom tuple data types whose items can be accessed by index positionor more convenientlyby name we also saw how to create "constantsby using variables with all uppercase names in the coverage of lists we saw that everything that can be done to tuples can be done to lists and thanks to lists being mutable they offer considerably more functionality than tuples this includes methods that modify the list