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.

EasyTechnical
20 practiced

Given a NumPy array a of shape (N, M), write Python code to compute a boolean mask of rows that contain any NaN using vectorized NumPy operations. Do not use Python loops.

EasyTechnical
36 practiced

Explain how to structure a Python package to make it easy to test and maintain: where to place tests, use of init.py, how to expose a stable public API, and how to run tests in CI. Include best practices for type stubs and documentation.

HardTechnical
24 practiced

Write a short Python function detect_deadlocks(thread_dump) that, given a list of thread lock acquisition traces (each trace is a list of lock ids a thread holds and then requests), detects whether a circular deadlock is possible. Provide algorithmic complexity and a brief correctness argument.

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
24 practiced

Given a DataFrame df with millions of rows, you need to compute a new column 'rank_within_group' that ranks values within each group defined by 'category' in descending order. Write an efficient Pandas solution and explain memory and performance trade-offs.

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.