InterviewStack.io LogoInterviewStack.io

Python Fundamentals and Core Syntax Questions

Comprehensive knowledge of core Python language features and syntax, including primitive and composite data types such as integer numbers, floating point numbers, strings, booleans, lists, dictionaries, sets, and tuples. Candidates should understand variable assignment and naming, operators for arithmetic, logical, and comparison operations, and control flow constructs including conditional statements and loops. Expect familiarity with function definition, invocation, parameter passing, return values, and scope rules, as well as common built in functions and idioms such as iteration utilities, list comprehensions, generator expressions, and basic functional utilities like map and filter. Candidates should demonstrate error and exception handling techniques and best practices for writing readable and maintainable code with modularization and clear naming. Practical skills include file input and output, working with common data formats such as comma separated values and JavaScript Object Notation, selecting appropriate data structures with attention to performance and memory characteristics, and applying memory efficient patterns for processing large data sets using iterators and generators. Familiarity with the standard library and common utilities for parsing and transforming data, and the ability to write small code snippets to solve algorithmic and data manipulation tasks, are expected.

EasyTechnical
0 practiced
Explain the difference between an iterable and an iterator in Python 3. Describe generator functions and generator expressions and why iterators can be exhausted. Give examples of bugs that come from accidentally reusing an exhausted iterator in a data pipeline and propose mitigations.
MediumTechnical
0 practiced
Implement stream_gzip_csv(path) in Python 3: a generator that opens a gzipped CSV file and yields each row as a dict using csv.DictReader. Ensure correct text mode and encoding, and discuss how you'd partition output rows by a given column into separate files while streaming without holding all data in memory.
HardTechnical
0 practiced
Implement streaming_histogram(iterable, num_bins) in Python 3: compute histogram bin edges and counts from a stream of numeric values without storing all values in memory. Describe a two-pass approach (estimate min/max then count) and single-pass alternatives (e.g., t-digest or adaptive bins), and discuss accuracy trade-offs with heavy-tailed distributions.
MediumTechnical
0 practiced
Write a Python 3 function sample_gzip_csv(path, sample_fraction=0.01) that yields a uniform random sample of rows from a gzipped CSV file without reading the whole file into memory. The sampling should be streaming and unbiased. Explain assumptions and why the algorithm works.
MediumTechnical
0 practiced
Tell me about a time when you discovered a performance or correctness issue in a Python-based data pipeline. Use the STAR method: describe the Situation, the Task you were responsible for, the Actions you took (technical and non-technical), and the Results (quantified if possible). Emphasize how you prioritized fixes, communicated with stakeholders, and verified the improvement.

Unlock Full Question Bank

Get access to hundreds of Python Fundamentals and Core Syntax interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.