What will `list(map(lambda x: x**2, filter(lambda x: x%2==0, range(10))))` return? Python ProfessionalHard Try Now
What does `functools.lru_cache` use as a cache key when decorating a function? Python ProfessionalHard Try Now
Which of the following correctly describes the behavior of `__slots__` in a Python class? Python ProfessionalHard Try Now
What is the purpose of Python’s __init_subclass__ cls parameter’s keyword arguments, and how are they passed? Python ProfessionalHard Try Now
What does the following code output? import asyncio async def producer(queue): for i in range(3): await queue.put(i) await queue.put(None) async def consumer(queue): while True: item = await queue.get() if item is None: break print(item) async def main(): q = asyncio.Queue() await asyncio.gather(producer(q), consumer(q)) asyncio.run(main()) Python ProfessionalHard Try Now
What is PEP 695 (Python 3.12) type parameter syntax and how does it simplify generic definitions? Python ProfessionalHard Try Now
What does the following pattern with __enter__ returning self enable? class Resource: def __enter__(self): return self def __exit__(self, *args): self.close() return False def close(self): pass with Resource() as r: print(r is not None) Python ProfessionalHard Try Now