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.

HardTechnical
18 practiced

Given a shared counter incremented by several threads in a tight loop with count += 1, why does the final count come out wrong even though the GIL exists? Provide a corrected, efficient version, and explain which Python operations are actually safe to share across threads without a lock and which aren't.

MediumTechnical
26 practiced

Why can a tuple be used as a dictionary key or set member while a list can't? Walk me through what makes an object hashable in Python, and what invariant must hold between hash and eq for a type to be safely usable as a key.

MediumTechnical
24 practiced

Your team wants one new automation tool that will be owned by a few engineers, run unattended every day, and occasionally do CPU-heavy parsing on large inputs. How would you choose between Python and Go for the implementation, and what factors would matter most beyond raw speed?

EasyTechnical
26 practiced

What does if __name__ == '__main__': actually do in Python? Show a small script that behaves differently when run directly versus imported as a module, and give a real reason you'd use this idiom.

MediumTechnical
18 practiced

Write a function that removes duplicates from a list while preserving the first-seen order. It only needs to handle hashable elements. Then explain the time and space complexity of your solution and how you'd adapt it if the input were far too large to hold a full result list in memory.

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.