34 questions for “Comprehensions & Generators”

Found in 1 field. Select a question to see its full answer.

Information Technology

34 questions in 3 technologies

#QuestionTechnologyTopicLevel
1How do dict comprehensions and set comprehensions differ in syntax from list comprehensions? Python › Comprehensions & GeneratorsPythonComprehensions & GeneratorsIntermediate
2How would you implement a coroutine-style generator-based pipeline (the classic pre-async/await pattern) using multiple chained 'send()'-driven generators? Python › Comprehensions & GeneratorsPythonComprehensions & GeneratorsAdvanced
3How do you write a basic list comprehension, and how does it compare to an equivalent for loop? Python › Comprehensions & GeneratorsPythonComprehensions & GeneratorsBeginner
4How do you add a filtering condition to a list comprehension using 'if'? Python › Comprehensions & GeneratorsPythonComprehensions & GeneratorsBeginner
5What is a generator function, and how does 'yield' make it different from a regular function? Python › Comprehensions & GeneratorsPythonComprehensions & GeneratorsBeginner
6What is a generator expression, and how does it differ syntactically and behaviorally from a list comprehension? Python › Comprehensions & GeneratorsPythonComprehensions & GeneratorsIntermediate
7How do you write a nested comprehension, like flattening a list of lists into a single flat list? Python › Comprehensions & GeneratorsPythonComprehensions & GeneratorsIntermediate
8How do you send a value INTO a generator using the .send() method, and how does this differ from just calling next()? Python › Comprehensions & GeneratorsPythonComprehensions & GeneratorsIntermediate
9How does 'yield from' delegate iteration to a sub-generator, and what does it return as its own expression value? Python › Comprehensions & GeneratorsPythonComprehensions & GeneratorsAdvanced
10How does generator.throw() let you inject an exception into a paused generator, and how would the generator handle it? Python › Comprehensions & GeneratorsPythonComprehensions & GeneratorsAdvanced