InterviewStack.io LogoInterviewStack.io

Python Programming & ML Libraries Questions

Python programming language fundamentals (syntax, data structures, control flow, error handling) with practical usage of machine learning libraries such as NumPy, pandas, scikit-learn, TensorFlow, and PyTorch for data manipulation, model development, training, evaluation, and lightweight ML tasks.

MediumTechnical
0 practiced
Write an async Python function using aiohttp and asyncio that concurrently downloads a list of URLs, limits concurrency to N simultaneous requests using a semaphore, reuses a single ClientSession, handles timeouts and cancellations gracefully, and writes responses to disk. Explain when async I/O is preferable for ML pipelines such as fetching many small files from remote stores.
HardTechnical
0 practiced
Implement a custom autograd Function in PyTorch in Python that computes a numerically stable softmax cross-entropy in one operation to reduce intermediate memory usage. Provide a class MyXent(torch.autograd.Function) with static forward and backward methods, using the log-sum-exp trick for stability, and describe what tensors must be saved in ctx for the backward pass. Also discuss ignore_index handling and per-sample weighting.
MediumTechnical
0 practiced
Explain how to implement a custom scikit-learn Transformer in Python (subclassing TransformerMixin and BaseEstimator) that creates polynomial interaction features for selected columns, integrate it into a Pipeline, and ensure it works with GridSearchCV. Provide code sketches and explain get_params/set_params behavior required for hyperparameter search.
MediumTechnical
0 practiced
Design a robust Python context manager (using contextlib or a class) to temporarily change and restore global state such as NumPy print options or a random seed. Provide code implementing __enter__ and __exit__ or using @contextmanager, ensuring restoration even on exceptions. Explain use cases in tests and debugging training runs.
MediumTechnical
0 practiced
Describe NumPy broadcasting rules in detail and illustrate with examples aligning arrays of shapes (3,1) and (1,4) to produce (3,4). Explain how broadcasting works with trailing axes, when dimensions must be 1 or equal, and provide tips to avoid accidental creation of huge temporaries that can blow memory. Include guidance on using np.expand_dims and np.broadcast_to to make intent explicit.

Unlock Full Question Bank

Get access to hundreds of Python Programming & ML Libraries interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.