InterviewStack.io LogoInterviewStack.io

Python Fundamentals and Problem Solving Questions

Comprehensive knowledge of the Python programming language, idiomatic usage, and the ability to implement correct, readable, and testable solutions to coding problems. Core language elements include syntax and semantics, primitive and composite data types such as integers, floats, strings, lists, dictionaries, sets, and tuples, sequence and mapping operations, control flow constructs, functions and closures, and object oriented programming basics including classes, instances, inheritance, and special methods. Additional practical topics include error and exception handling, file input and output operations, comprehensions and generator expressions, generator functions and iteration protocols, context managers, lambda functions, unpacking, and common standard library utilities. Candidates should understand algorithmic time and space complexity for common operations, typical performance characteristics of lists and dictionaries, and common pitfalls such as mutable default arguments and shared mutable state. Interview focused expectations include writing clean correct code without editor assistance, sensible variable naming, implementing basic algorithms and data structure manipulations under time constraints, reasoning about tradeoffs and complexity, and demonstrating testability and code quality.

HardTechnical
0 practiced
Design and implement a thread-safe, memory-efficient LRU cache in Python with a fixed capacity and optional TTL (time-to-live) per key. Do not use functools.lru_cache; standard library data structures are allowed. The cache must support get(key) and set(key, value) and be safe for concurrent access from multiple threads.
MediumTechnical
0 practiced
Implement a Python function that merges two sorted lists of tuples by their key field and yields aggregated results (e.g., summing values for equal keys). Input format: list of (key, value) pairs. The solution should be streaming (O(1) extra memory) and suitable for datasets larger than memory when fed as generators.
MediumTechnical
0 practiced
Write a Python generator `flatten(nested)` that lazily flattens arbitrarily nested lists or tuples of elements into a single stream of leaf elements. Your function must treat strings as atomic (do not iterate into characters). Provide examples and discuss recursion depth and iterative alternatives.
HardTechnical
0 practiced
Implement the Quickselect algorithm in Python to find the kth smallest element of an unsorted list in expected O(n) time. Provide an in-place partition implementation, and explain how random pivot choice mitigates worst-case performance. Include example input and output.
MediumTechnical
0 practiced
Implement a function `kth_largest(nums: List[int], k: int) -> int` in Python using heapq that returns the kth largest element in an unsorted list. The function should work efficiently for large lists and you should explain time and space complexity. Also briefly sketch how you would implement quickselect and when it might be preferred.

Unlock Full Question Bank

Get access to hundreds of Python Fundamentals and Problem Solving interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.