InterviewStack.io LogoInterviewStack.io

Python Fundamentals and Problem Solving Questions

Comprehensive knowledge of the Python programming language, idiomatic usage, and the ability to implement correct, readable, and testable solutions to coding problems. Core language elements include syntax and semantics, primitive and composite data types such as integers, floats, strings, lists, dictionaries, sets, and tuples, sequence and mapping operations, control flow constructs, functions and closures, and object oriented programming basics including classes, instances, inheritance, and special methods. Additional practical topics include error and exception handling, file input and output operations, comprehensions and generator expressions, generator functions and iteration protocols, context managers, lambda functions, unpacking, and common standard library utilities. Candidates should understand algorithmic time and space complexity for common operations, typical performance characteristics of lists and dictionaries, and common pitfalls such as mutable default arguments and shared mutable state. Interview focused expectations include writing clean correct code without editor assistance, sensible variable naming, implementing basic algorithms and data structure manipulations under time constraints, reasoning about tradeoffs and complexity, and demonstrating testability and code quality.

MediumTechnical
55 practiced
Implement a Python generator `merge_sorted(a, b)` that merges two sorted iterators of integers into a single sorted iterator without converting iterators to lists. Explain how this approach is useful for merging sorted partitions during a reduce step in a distributed pipeline.
MediumTechnical
51 practiced
Write a Python decorator `retry` that retries a function call when it raises an exception, with parameters `retries`, `initial_delay`, and `backoff_factor`. The decorator should be usable on any function and should not swallow the final exception. Show example usage and explain blocking vs non-blocking behavior.
MediumTechnical
48 practiced
Explain the difference between shallow and deep copy in Python. Give examples using nested lists and custom objects, show how to create deep copies using the `copy` module, and explain scenarios where `copy.copy()` is insufficient in ETL transformations.
EasyTechnical
43 practiced
Implement a Python function `unique_preserve_order(items: Iterable[T]) -> List[T]` that returns unique elements preserving their first-seen order. The implementation should be efficient and work for hashable elements. Describe complexity and how to extend it to unhashable elements (e.g., dicts).
MediumTechnical
50 practiced
Explain the difference between `zip` and `itertools.zip_longest`. Describe a memory-efficient strategy to process three large files line-by-line in lockstep, accounting for missing lines in shorter files and aligning fields with padding where necessary.

Unlock Full Question Bank

Get access to hundreds of Python Fundamentals and Problem Solving interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.