Technical screening interviews for Data Science and Machine Learning roles almost always include a 45-minute live coding assessment in Python, Pandas, and NumPy. Here are 50 production-level coding questions with clean, optimized solutions.
1. How do you find the top 3 highest-spending customers per region in a 1M-row DataFrame without slow loops?
import pandas as pd
# Optimized Groupby + Rank
df['rank'] = df.groupby('region')['total_spend'].rank(method='dense', ascending=False)
top_3_per_region = df[df['rank'] <= 3].sort_values(['region', 'rank'])
2. How does NumPy broadcasting work when adding a (3, 1) matrix to a (1, 4) row vector?
NumPy compares shapes element-wise starting from trailing dimensions. A dimension is compatible if they are equal or if one of them is 1. When adding shape (3, 1) and (1, 4), both arrays are broadcasted to shape (3, 4) without copying memory buffers.
Master Python for Data Science from Scratch
Join AI Campus Data Science with Python. 100% live interactive batches, IBM & Microsoft credentials, and a Guaranteed 6-Month Paid Corporate Internship* (₹80k / ₹6,666 EMI).
Explore Python Data Science Track →Data Science, Python, Machine Learning & GenAI
Master Python, SQL, XGBoost, PyTorch & RAG with official IBM & Microsoft credentials + Guaranteed 6-Month Paid Corporate Internship* (₹80,000 / ₹6,666 per month 0% EMI).
