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
0 practiced
You receive JSON records from multiple data providers where keys may be missing, extra, or have inconsistent types. As a Python ML engineer, outline a robust parsing and normalization strategy you would implement in production. Include examples of defensive code patterns in Python 3 using dict.get, type casting, default values, and how you would log or surface malformed records.
MediumTechnical
0 practiced
Explain why it is unsafe to unpickle data from untrusted sources in Python. Provide safe alternatives for serializing ML artifacts and a short Python 3 example showing how to write and read newline-delimited JSON (ndjson) as a safer option than pickle for simple data records.
MediumTechnical
0 practiced
Implement a small Python 3 command-line utility 'jsonlines_to_csv' that reads newline-delimited JSON from stdin or a file and writes CSV to stdout or a file, extracting a specified list of fields in order. Handle missing fields by leaving CSV cells empty and ensure proper quoting of values. Provide the argparse interface and a brief implementation sketch.
EasyTechnical
0 practiced
Implement a Python 3 decorator 'retry_on_ioerror(retries, initial_backoff_seconds)' that retries a decorated function when it raises an IOError or OSError, using exponential backoff with optional jitter. The decorator should re-raise the last exception if retries are exhausted. Provide example usage and discuss when retries are appropriate in ML data ingestion.
HardTechnical
0 practiced
Write a safe expression evaluator in Python 3 that evaluates simple arithmetic expressions input as strings (operators +, -, *, /, parentheses, and numeric literals) without using eval. Use the ast module to parse and whitelist allowed AST nodes, and return the numeric result or raise a descriptive exception for disallowed constructs.

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.