All fields

“Comprehensions & Generators” in Information Technology

34 questions across 3 technologies.

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
11How does lazy evaluation in a chained sequence of generator expressions actually process elements, one at a time end-to-end, without intermediate lists? Python › Comprehensions & GeneratorsPythonComprehensions & GeneratorsAdvanced
12How would you implement a memory-efficient sliding window or batching generator over a large iterable? Python › Comprehensions & GeneratorsPythonComprehensions & GeneratorsAdvanced
13How do you correctly close a generator early and ensure any try/finally cleanup inside it still runs? Python › Comprehensions & GeneratorsPythonComprehensions & GeneratorsAdvanced
14How do you write a comprehension with MULTIPLE 'if' conditions, and how does that differ from combining them with 'and'? Python › Comprehensions & GeneratorsPythonComprehensions & GeneratorsAdvanced
15How would you profile whether a generator expression is actually providing a measurable memory or performance benefit over a list comprehension in a specific use case? Python › Comprehensions & GeneratorsPythonComprehensions & GeneratorsAdvanced
16How do async comprehensions work, combining 'async for' directly inside a list/set/dict comprehension? Python › Async Generators & Async Context ManagersPythonAsync Generators & Async Context ManagersIntermediate
17How do you build an async generator pipeline, chaining one async generator's output into another, like a synchronous generator pipeline? Python › Async Generators & Async Context ManagersPythonAsync Generators & Async Context ManagersIntermediate
18What is the relationship between generators and the iterator protocol? Python › Iterators & the Iterator ProtocolPythonIterators & the Iterator ProtocolIntermediate
19How can generators and iterators help reduce peak memory usage compared to building full lists? Python › Memory Management & Garbage CollectionPythonMemory Management & Garbage CollectionAdvanced
20What is the difference between an iterable and an iterator in Python? Python › Iterators & the Iterator ProtocolPythonIterators & the Iterator ProtocolBeginner
21What does the built-in next() function's optional default argument do? Python › Iterators & the Iterator ProtocolPythonIterators & the Iterator ProtocolBeginner
22Why do you need the 'global' keyword to MODIFY a global variable from inside a function, but not to simply READ it? Python › Functions & ScopePythonFunctions & ScopeIntermediate
23What does functools.reduce do, and why is it often discouraged in favor of loops? Python › functools & Functional Programming ToolsPythonfunctools & Functional Programming ToolsIntermediate
24What does functools.reduce's initializer argument do, and why should you usually provide one? Python › functools & Functional Programming ToolsPythonfunctools & Functional Programming ToolsIntermediate
25What is the practical difference between using functools.reduce and a plain for-loop for accumulation? Python › functools & Functional Programming ToolsPythonfunctools & Functional Programming ToolsIntermediate
26How do you implement a custom iterator by defining __iter__ and __next__? Python › Iterators & the Iterator ProtocolPythonIterators & the Iterator ProtocolIntermediate
27How does the itertools module complement the iterator protocol? Python › Iterators & the Iterator ProtocolPythonIterators & the Iterator ProtocolIntermediate
28What is the difference between iter(obj) and using obj directly in a for-loop, in terms of what Python calls internally? Python › Iterators & the Iterator ProtocolPythonIterators & the Iterator ProtocolIntermediate
29What is the difference between IQueryable<T> and IEnumerable<T> when writing EF Core queries, and why does it matter for performance? .NET › Entity Framework Core & Data Access.NETEntity Framework Core & Data AccessIntermediate
30What is LINQ, and how does it simplify querying collections compared to writing manual loops? C# › LINQC#LINQIntermediate
31How does a closure capture variables from its enclosing scope, and what pitfall occurs when creating multiple closures inside a loop? Python › Functions & ScopePythonFunctions & ScopeAdvanced
32How does functools.cmp_to_key bridge old-style comparison functions with Python 3's key-based sorting? Python › functools & Functional Programming ToolsPythonfunctools & Functional Programming ToolsAdvanced
33What is the difference between __iter__ returning self versus returning a separate iterator object? Python › Iterators & the Iterator ProtocolPythonIterators & the Iterator ProtocolAdvanced
34How would you implement a lazy, chainable iterator pipeline (like filter-then-map) from scratch? Python › Iterators & the Iterator ProtocolPythonIterators & the Iterator ProtocolAdvanced