InterviewStack.io LogoInterviewStack.io

Python Programming Questions

Python as an interview language: core syntax, data types and built-in collections, comprehensions, iterators and generators, idiomatic style, and the standard library, extending into data-oriented and automation use of the language and its common libraries. Covers writing correct, Pythonic code and reasoning about the language's semantics. The most heavily exercised language surface in this category across engineering and data roles.

MediumTechnical
19 practiced

You're reviewing a pull request that replaces many small NumPy operations with chained expressions that create several temporaries, causing a memory regression. Provide a review checklist and concrete suggestions (code-level) to improve memory usage while keeping code readable.

EasyTechnical
19 practiced

Write a Python function flatten_list(nested) that takes a list which may contain nested lists to arbitrary depth and returns a flat list with all values in original order. Provide an implementation using an iterative approach (no recursion). Describe its time and space complexity.

MediumTechnical
22 practiced

Write an async function gather_with_timeout(coros, timeout) in Python 3.8+ that schedules multiple coroutines and returns a tuple (done, pending) similar to asyncio.wait but cancels pending after timeout and ensures any exceptions are propagated. Include a small usage example.

MediumTechnical
18 practiced

A report generator currently scans the same task records multiple times to answer different summary questions, and the runtime is starting to hurt as the team grows. How would you reason about the bottleneck, and what would you change in the data flow so repeated lookups get faster without making the codebase hard to maintain?

MediumTechnical
26 practiced

Implement a function top_k_frequent(iterable, k) that returns the k most frequent items and their counts. Your solution must handle very large iterables (possibly streaming) and have O(n) expected time with O(k) additional memory where possible. Use Python.

Unlock Full Question Bank

Get access to all 46 Python Programming interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.