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.

MediumTechnical
69 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.
EasyTechnical
75 practiced
List five Python standard library modules that are especially useful for data engineering (e.g., parsing, compression, concurrency, data structures). For each module give one sentence describing a typical ETL use-case where you'd reach for it.
MediumTechnical
86 practiced
Write Python 3 code that reads a large NDJSON file and writes a standard JSON array to an output file without loading all objects into memory. Ensure proper JSON formatting (commas between items, no trailing comma). Discuss how to make the write atomic and how to test this behavior.
MediumTechnical
80 practiced
Write a Python 3 function flatten_json(obj, parent_key='', sep='.') that flattens a nested JSON-like structure to a single-level dict mapping compound keys to values (for example, {'a': {'b': 1}} -> {'a.b': 1}). The function should handle nested lists by including numeric indices in keys and should avoid recursion depth limits when structures are very deep by using an iterative approach.
MediumTechnical
84 practiced
Implement dicts_to_csv(rows, columns, out_path) in Python 3 that writes an iterable of dicts to a CSV file with the specified column order, proper quoting, UTF-8 encoding, and handling of missing values by writing empty strings. Use csv.DictWriter and ensure the function is safe for streaming large iterables.

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.