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

Explain the difference between a list comprehension, generator expression, and using map/filter in Python. When would you prefer each? Give a short code example (2-3 lines) for each showing how to square numbers 0..9.

EasyTechnical
27 practiced

Your operations team gets weekly status items from different managers, but the same item can appear with different capitalization, extra spaces, or punctuation. In Python, write a function that normalizes the titles, removes duplicates while preserving the first occurrence, and returns the cleaned list. Assume a few thousand strings at most.

MediumTechnical
19 practiced

For list.append, list.pop(), list.pop(0), list.insert(0, x), and list.index(x), what is the time complexity of each and why? Then look at this snippet: a function that builds a list with repeated insert(0, ...) calls inside a loop, and another that does linear scans with in inside a loop. What's the actual complexity of each function, and how would you fix it?

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.

HardTechnical
24 practiced

You're designing the public exception types for a library other teams will depend on. When do you define custom exception classes versus reusing built-ins, how narrow should an except clause be, and how do you use exception chaining (raise ... from ...) to preserve the original cause?

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.