*args vs **kwargs
*args captures extra positional arguments and **kwargs captures extra keyword arguments.
- args becomes tuple
- kwargs becomes dict
- Useful for flexible APIs
*args vs **kwargs
Python cards
*args captures extra positional arguments and **kwargs captures extra keyword arguments.
*args vs **kwargs
Python exception handling is strongest when you catch specific built-in errors, use `else` for the success path, `finally` for cleanup, and custom exceptions when domain meaning matters.
Built-in exceptions, try/except/else/finally, custom exceptions, and chaining
`bytes` is immutable binary data, `bytearray` is mutable binary data, and `range` is a memory-efficient arithmetic sequence object.
Bytes, bytearray, and range in Python
A class defines shared behavior, each object holds instance state, `self` refers to the current instance, and `__init__` initializes it.
Classes, objects, `self`, `__init__`, and class vs instance variables
These helpers reduce boilerplate for grouping, counting, queue behavior, lightweight record types, partial application, reduction, and memoization.
collections and functools helpers: `defaultdict`, `Counter`, `deque`, `namedtuple`, `partial`, `reduce`, and `lru_cache`
Interview prep often comes down to comparing similar tools and explaining when each one is the better fit.
Common Python comparison topics: set vs list, append vs extend, remove vs pop vs del, sort() vs sorted(), @staticmethod vs @classmethod, and generator vs iterator
Special methods let your objects behave like built-in types in printing, indexing, length checks, and membership operations.
Common special methods like `__str__`, `__repr__`, `__len__`, `__getitem__`, and `__contains__`
Python uses `if`/`elif`/`else` for general branching, a ternary expression for concise value selection, and `match-case` for structural pattern matching in newer versions.
Conditional statements, ternary expressions, and match-case basics
Core Python data types include numbers, strings, lists, tuples, sets, dictionaries, booleans, and `None`.
Core data types in Python
Default argument values are evaluated once at function definition time, which makes mutable defaults a common bug source.
Default arguments and mutable default values