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
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.

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.

HardSystem Design
26 practiced

You need to package a Python library used in data science which includes compiled C extensions and optional GPU support. Outline a cross-platform build and distribution strategy that simplifies installation for users on Linux, macOS, and Windows. Include CI steps and how you'd support pip installs.

MediumTechnical
19 practiced

Write code that safely runs an external command via subprocess: avoiding shell injection, enforcing a timeout, and capturing stdout/stderr without leaving zombie or orphaned child processes behind.

MediumTechnical
22 practiced

Write a function that converts a messy numeric string, things like '1,234.56', '$1.2M', 'NaN', or an empty string, into a float, returning None for anything unparseable. Would you check the input's shape before converting (look before you leap) or just try the conversion and catch the exception (ask forgiveness)? Justify your choice here.

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.