Practice Python questions covering data structures, decorators, generators, comprehensions, and Pythonic programming patterns.
Built-in data structures (lists, dicts, sets, tuples), list comprehensions, generators, decorators, context managers, OOP in Python, exception handling, and the standard library (collections, itertools). For data roles, also know NumPy, Pandas, and basic ML concepts.
Python is excellent for interviews. Its concise syntax lets you write solutions quickly, and its rich standard library (collections.Counter, heapq, defaultdict) simplifies many problems. Most FAANG companies accept Python, and it's the most popular choice among candidates.
Decorators are functions that modify other functions. They use the @decorator syntax and wrap a function to add behavior before/after it runs. Common uses include logging, timing, authentication, and caching. Understanding closures is key to understanding decorators.
Lists are mutable (can be modified after creation) while tuples are immutable. Tuples are slightly faster and can be used as dictionary keys. Use tuples for fixed data like coordinates or database rows, and lists when you need to add, remove, or modify elements.
Generators are functions that use yield instead of return, producing values one at a time lazily. They save memory by not storing the entire sequence. Generator expressions (x for x in range(n)) are the expression form. They are ideal for processing large datasets or infinite sequences.
The Global Interpreter Lock (GIL) in CPython prevents true parallel execution of Python bytecode across threads. CPU-bound tasks should use multiprocessing instead of threading. I/O-bound tasks (network, file) still benefit from threading because the GIL is released during I/O operations.