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
58 practiced
Write an asyncio-based function fetch_all(urls, max_concurrency=10) that concurrently fetches many URLs using a session object and respects max_concurrency with a semaphore. Sketch how you would implement retries with exponential backoff for transient errors and return a list of response texts while handling exceptions gracefully.
MediumTechnical
46 practiced
Implement a Python context manager Timer usable as: with Timer('train') as t: ... ; on exit it should log elapsed wall time and allow using t.elapsed to get seconds. Provide a robust implementation as a class with __enter__/__exit__ and consider exception handling in the block.
MediumTechnical
48 practiced
Implement atomic_write(path, data) that writes bytes data to disk atomically so readers never observe a partially written file. Use a safe POSIX approach: write to a temporary file in the same directory, fsync the file, and then atomically replace the target. Explain edge cases and durability guarantees.
HardTechnical
55 practiced
Implement a thread-safe cached_property descriptor: the first access computes the value and caches it on the instance, subsequent accesses return the cached value, and deleting the attribute forces recomputation. Ensure the implementation avoids race conditions when used by multiple threads.
HardTechnical
59 practiced
Explain metaclasses in Python and implement a metaclass RegistryMeta that automatically registers every subclass of a base class into a global registry mapping class name to class. Demonstrate usage by registering a few example subclasses and retrieving them by name.

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.