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
82 practiced
Describe CPython's memory model regarding small integer caching and string interning. Explain how interning affects performance and identity comparisons, and provide concrete examples where 'is' may return True for small integers or interned strings.
HardTechnical
122 practiced
Implement a Python iterator class Peekable that wraps any iterator and supports peek() to view the next element without consuming it, and pushback(value) to place a value back into the stream so subsequent next() returns it. Ensure correct behavior for multiple pushes and for an exhausted underlying iterator.
EasyTechnical
60 practiced
Using Python's json module, write a function extract_field(json_string, path) that takes a JSON string representing a nested object and a dotted path like 'user.profile.email' and returns the value or None if any part of the path is missing. Show an example input and expected output.
MediumTechnical
104 practiced
Implement a Python generator function stream_csv_dicts(file_path) that opens a CSV file and yields each row as a dict mapping column name to value, using csv.DictReader. Ensure your implementation streams rows lazily and works for very large files without reading them entirely into memory.
HardTechnical
71 practiced
Implement the Misra-Gries algorithm (a deterministic k-heavy hitters algorithm) in Python to find items that may appear more than n/k times in a stream. The function should accept an iterable and k and return candidate items and their estimated counts. Discuss algorithm accuracy and memory guarantees.

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.