{'ac''bd''bc''ad'{ (ord( )ord( )for in 'abfor in 'cd'{'ac'( )'bd'( )'bc'( )'ad'( ){ for in ['spam''ham''sausage'if [ =' '{'sausagesausage''spamspam'{ upper() for in ['spam''ham''sausage'if [ =' '{'sausage''sausagesausage''spam''spamspam'for more detailsexperiment with these tools on your own they may or may not have performance advantage over the generator or for loop alternativesbut we would have to time their performance explicitly to be sure--which seems natural segue to the next summary this wrapped up our coverage of built-in comprehension and iteration tools it explored list comprehensions in the context of functional toolsand presented generator functions and expressions as additional iteration protocol tools as finalewe also summarized the four forms of comprehension in python today--listgeneratorsetand dictionary though we've now seen all the built-in iteration toolsthe subject will resurface when we study user-defined iterable class objects in the next is something of continuation of the theme of this one--it rounds out this part of the book with case study that times the performance of the tools we've studied hereand serves as more realistic example at the midpoint in this book before we move ahead to benchmarking comprehensions and generatorsthoughthis quizzes give you chance to review what you've learned about them here test your knowledgequiz what is the difference between enclosing list comprehension in square brackets and parentheses how are generators and iterators related how can you tell if function is generator function what does yield statement do how are map calls and list comprehensions relatedcompare and contrast the two test your knowledgeanswers list comprehensions in square brackets produce the result list all at once in memory when they are enclosed in parentheses insteadthey are actually generator comprehensions and generations