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

Explain how vectorized operations in NumPy and Pandas can be faster than explicit Python loops. Describe one situation where vectorization might be slower and why.

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.

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.

MediumTechnical
22 practiced

Python's sort is stable and adaptive (Timsort). What does stability actually buy you when you need to sort by more than one key, and what's the difference between list.sort() and the builtin sorted() in terms of what they return and when you'd choose one over the other?

MediumTechnical
21 practiced

What are the risks of using pickle to load data or models from a source you don't fully trust? What safer alternatives would you reach for instead, and if you had to accept pickle input anyway, how would you restrict what it's allowed to deserialize?

Unlock Full Question Bank

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

Sign in to Continue

Join thousands of developers preparing for their dream job.