All fields

“Iterators & the Iterator Protocol” in Information Technology

27 questions across 2 technologies.

Information Technology

27 questions in 2 technologies

#QuestionTechnologyTopicLevel
1How does the itertools module complement the iterator protocol? Python › Iterators & the Iterator ProtocolPythonIterators & the Iterator ProtocolIntermediate
2What is the relationship between generators and the iterator protocol? Python › Iterators & the Iterator ProtocolPythonIterators & the Iterator ProtocolIntermediate
3How does the iterator protocol interact with the with-statement for resource-managing iterables like file objects? Python › Iterators & the Iterator ProtocolPythonIterators & the Iterator ProtocolAdvanced
4What is the difference between an iterable and an iterator in Python? Python › Iterators & the Iterator ProtocolPythonIterators & the Iterator ProtocolBeginner
5How do you implement a custom iterator by defining __iter__ and __next__? Python › Iterators & the Iterator ProtocolPythonIterators & the Iterator ProtocolIntermediate
6What is the difference between __iter__ returning self versus returning a separate iterator object? Python › Iterators & the Iterator ProtocolPythonIterators & the Iterator ProtocolAdvanced
7How would you implement a lazy, chainable iterator pipeline (like filter-then-map) from scratch? Python › Iterators & the Iterator ProtocolPythonIterators & the Iterator ProtocolAdvanced
8How does itertools.tee let you iterate over the same iterator multiple times independently? Python › Iterators & the Iterator ProtocolPythonIterators & the Iterator ProtocolAdvanced
9What exception signals the end of iteration, and how does a for-loop use it internally? Python › Iterators & the Iterator ProtocolPythonIterators & the Iterator ProtocolBeginner
10What does the built-in next() function's optional default argument do? Python › Iterators & the Iterator ProtocolPythonIterators & the Iterator ProtocolBeginner
11How do you manually exhaust and inspect an iterator without a for-loop? Python › Iterators & the Iterator ProtocolPythonIterators & the Iterator ProtocolBeginner
12How does Python's iter() function work with a sentinel value as a second argument? Python › Iterators & the Iterator ProtocolPythonIterators & the Iterator ProtocolIntermediate
13How does Python know whether to treat a for-in target as iterable, and what error occurs if it isn't? Python › Iterators & the Iterator ProtocolPythonIterators & the Iterator ProtocolIntermediate
14What 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
15How does itertools.groupby depend on input order, and what's a common mistake when using it? Python › Iterators & the Iterator ProtocolPythonIterators & the Iterator ProtocolAdvanced
16How can generators and iterators help reduce peak memory usage compared to building full lists? Python › Memory Management & Garbage CollectionPythonMemory Management & Garbage CollectionAdvanced
17What is the practical difference between using functools.reduce and a plain for-loop for accumulation? Python › functools & Functional Programming ToolsPythonfunctools & Functional Programming ToolsIntermediate
18How does __contains__ let you customize the behavior of the 'in' operator? Python › Magic Methods & Operator OverloadingPythonMagic Methods & Operator OverloadingIntermediate
19How would you implement a custom async iterator class from scratch, without using an async generator function? Python › Async Generators & Async Context ManagersPythonAsync Generators & Async Context ManagersAdvanced
20How does __bool__ (or the legacy __nonzero__) determine an object's truthiness, and what's the fallback if it's not defined? Python › Magic Methods & Operator OverloadingPythonMagic Methods & Operator OverloadingAdvanced
21What is a generator function, and how does 'yield' make it different from a regular function? Python › Comprehensions & GeneratorsPythonComprehensions & GeneratorsBeginner
22How do slicing operations work on a list, including negative indices and step values? Python › Data Types & StructuresPythonData Types & StructuresIntermediate
23What does functools.reduce do, and why is it often discouraged in favor of loops? Python › functools & Functional Programming ToolsPythonfunctools & Functional Programming ToolsIntermediate
24How do __len__, __getitem__, and __setitem__ let a custom class act like a sequence or mapping? Python › Magic Methods & Operator OverloadingPythonMagic Methods & Operator OverloadingIntermediate
25How do you implement server-streaming gRPC using C#'s IAsyncEnumerable<T> or IServerStreamWriter<T>? .NET › gRPC Services.NETgRPC ServicesIntermediate
26How does 'yield from' delegate iteration to a sub-generator, and what does it return as its own expression value? Python › Comprehensions & GeneratorsPythonComprehensions & GeneratorsAdvanced
27How do you use conditional breakpoints in pdb to pause execution only when a specific condition is met, avoiding manually stepping through many unrelated iterations? Python › Debugging & ProfilingPythonDebugging & ProfilingAdvanced