Variables and types
Python is dynamically typed: names bind to objects, and the type lives on the object. The core built-ins are int (arbitrary precision, so no overflow), float, bool, str and None. Know the conversions for parsing input and float('inf') for min/max sentinels.
Operators
Arithmetic, comparison, identity, bitwise and conditional operators. The common traps are // and % on negative numbers (Python floors, C/Java truncate), is vs ==, and bit tricks for subset enumeration and flags.
if / elif / else
Conditional branching. Python has no switch (see match) and no braces; indentation defines blocks. Lean on truthiness for empty checks, but use x is None when 0 or "" are valid values.
match statement
Structural pattern matching (3.10+): matches a value against patterns and destructures it in one step. Handy in LLD for command/event dispatch and parsing tokens; in DSA it mostly replaces if/elif chains on operators or tuple shapes.
for loop
Iterates over any iterable: list, str, range, dict, set or generator. Use range for index loops, enumerate when you need index and value, zip to walk sequences in parallel, and break/else for early exit.
while loop
Loops while a condition is truthy. Use it when the number of iterations isn't known up front: BFS queues, stack processing, two pointers, binary search, and simulation loops.
Comprehensions
Concise expressions that build a list, dict, set or generator from an iterable. Use them for transforms, filters, frequency maps and grid initialization. Generator expressions are lazy, so pass them straight to sum, max, any or all to avoid building a list.
Unpacking
Assign elements of an iterable to multiple names in one statement. Used everywhere: swapping, popping (dist, node) off a heap, iterating pairs, and spreading arguments with ` and *`.
Functions
Define with def, return with return (implicitly None). Common patterns: nested helpers like def dfs(...) inside a method, closures that update outer state with nonlocal, and lambdas as sort keys.
Exceptions
Raise and handle errors with try/except. In LLD, define custom exception classes and raise them for invalid state; in DSA, try is rare but useful for parsing input or catching KeyError/IndexError.
Copying and mutability
Assignment never copies; it binds another name to the same object. Lists, dicts and sets are mutable, so aliasing bugs show up in grid initialization, default arguments and backtracking. Know when you need a shallow vs deep copy.
Comments and docstrings
# starts a comment that runs to the end of the line; Python has no block-comment syntax, so use consecutive # lines. A docstring is a string literal as the first statement of a module, function, class or method; it's stored on doc and shown by help(). Comment the why (invariants, complexity, edge cases) rather than restating the code, and give public classes and methods a one-line docstring in LLD code.