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.

HardTechnical
0 practiced
Production CSV files come with inconsistent encodings and occasionally produce UnicodeDecodeError during training runs. As an ML engineer, propose a robust Python 3 strategy to detect and handle encodings, including runtime detection, fallback encodings, safe decoding with errors handlers, logging, and testing to avoid data corruption. Mention standard library tools and pragmatic fallbacks.
EasyTechnical
0 practiced
Write a Python 3 generator function 'read_ndjson(path)' that streams lines from a large newline-delimited JSON (ndjson) file and yields parsed dicts. The generator should skip and log malformed lines but continue processing. Explain how this pattern helps when pre-processing large datasets for ML training.
HardTechnical
0 practiced
Design a reproducible shuffling strategy in Python for reading training data across multiple workers in parallel. Describe how you would seed random generators deterministically per epoch and per worker, how to partition data files or indices among workers, and how to handle non-determinism from file system ordering. Provide code sketches using the standard random module or numpy RNGs.
MediumTechnical
0 practiced
A Python-based model serving process leaks memory gradually in production. Describe the debugging steps you would take to find and fix the leak using standard Python tools (tracemalloc, gc, objgraph, logging). Include a prioritized list of quick mitigations you might apply to reduce the business impact while you find a permanent fix.
EasyTechnical
0 practiced
Write a Python 3 function that checks whether an input string is a palindrome ignoring punctuation, whitespace, and letter case. The function should handle Unicode characters robustly and return True/False. Example: input 'A man, a plan, a canal: Panama' should return True. Do not use external libraries; show how you would test your function on sample inputs.

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.