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.
Implement a context manager class timed_block that measures elapsed wall-clock time inside a with block and logs it using the logging module at INFO level. Provide a usage example.
Implement a memory-efficient CSV reader in Python that streams rows and yields namedtuples for each row, converting numeric-looking fields to int/float when appropriate. The function should accept a file path or file-like object and a chunk_size parameter controlling internal buffering.
You receive a very large newline-delimited export of overdue tickets that cannot fit in memory. In Python, how would you process it so memory stays bounded, skip blank or malformed lines, and compute the totals needed for a daily report? Describe the code structure you would use and the tradeoffs you would make.
A data pipeline intermittently produces different results on different runs (non-deterministic). List possible Python-language and library causes (e.g., dict ordering, floating-point reductions, parallelism) and propose concrete fixes to achieve determinism for production runs.
Given a Python program that is CPU-bound, describe three strategies to speed it up using standard CPython tools or libraries. For each, explain benefits, limitations, and when you'd choose it.
Unlock Full Question Bank
Get access to all 46 Python Programming interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.