Each question has a short model answer. In a real interview, add an example from your own code wherever you can.
is and ==? == checks whether two values are equal; is checks whether two names point to the exact same object in memory.def add(item, items=[]) a bug? Default arguments are created once, when the function is defined, so the same list is shared across calls. Use items=None and create a new list inside the function.args and *kwargs? args collects extra positional arguments into a tuple; *kwargs collects extra keyword arguments into a dictionary.@decorator_name.yield to produce values one at a time, only when asked. It saves memory when working with large or infinite sequences.copy.deepcopy) duplicates everything, including nested objects.multiprocessing. (Newer Python versions offer an optional free-threaded build.)[x*x for x in nums] builds the whole list in memory; (x*x for x in nums) produces values lazily, one at a time.else and finally do in a try block? else runs only if no exception was raised; finally always runs, which makes it the place for cleanup.__init__ and __new__? __new__ creates the object; __init__ initializes it after creation. You rarely need to override __new__.var, let, and const? var is function-scoped and hoisted with the value undefined. let and const are block-scoped; const cannot be reassigned, though an object it holds can still be changed.== vs ===? == converts types before comparing (0 == "" is true); === compares value and type (0 === "" is false). Use === by default.let and const are hoisted but cannot be used before their line (the temporal dead zone).this work? It depends on how a function is called: the object before the dot for methods, the new object with new, and undefined (in strict mode) for a plain call. Arrow functions take this from the surrounding scope.