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
76 practiced
Implement an LRUCache class in Python with methods get(key) and put(key, value) supporting O(1) operations and a maximum capacity that evicts the least-recently-used entries. You may use collections.OrderedDict or implement your own doubly linked list + dict. Mention thread-safety considerations.
HardTechnical
85 practiced
You implemented grouping over 10M event dicts using nested loops causing O(n^2) behavior. Describe and implement an efficient Python approach to compute per-user total and count in a single pass using appropriate data structures. Explain time and space complexity and discuss worst-case scenarios (e.g., extremely high cardinality).
MediumTechnical
67 practiced
Design a Python function add_metric(metrics, key, value, metadata=None) that appends a measurement to a metrics dict-of-lists structure. Implement this function safely to avoid the common mutable default argument pitfall, and include a short docstring and example usage in a BI aggregation pipeline.
MediumTechnical
80 practiced
Write a Python function read_jsonlines(path, encoding='utf-8') that yields parsed JSON objects from a file where each line is a JSON document. The function should handle invalid UTF-8 bytes by replacing them and skip malformed JSON lines while logging their line numbers to stderr. Use only the standard library.
HardTechnical
86 practiced
A nightly ETL takes 3 hours and you suspect Python code is the bottleneck. Describe a systematic approach to profile the script, list specific tools you would use (e.g., cProfile, line_profiler, memory_profiler), and enumerate code-level optimizations you might apply (algorithmic changes, data-structure swaps, and micro-optimizations).

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.