Canonical: this is a cross-post. The original lives at in exactly that shape. Those lists optimize for the wrong thing.
I've sat on the interviewing side of enough Python screens to know what actually moves a decision, and it's almost never whether the candidate could recite the definition of a decorator. It's whether they could read a stack trace without flinching, whether they reached for a list comprehension or a four-line loop, whether they knew when a Pandas operation was about to blow up memory. Those signals don't show up on a flashcard.
This guide does something different. For every question, you get a short version of the strong answer, then the part that matters: what the question actually predicts about you on the job, and a trivia tax flag when the question rewards memorization more than skill. Use it to spend your prep hours where they count.
Why most Python question lists waste your prep time
Python is everywhere in interviews because it's everywhere in work. In the of 67 interviewers (52 of them at FAANG companies), 81 percent suspected candidates of using AI to cheat and 75 percent believed AI assistance was letting weaker candidates pass interviews they'd otherwise fail. The response has been more follow-up questions, more "walk me through why you did that," more probing of whether you understand the code on the screen. A memorized answer survives the first question and falls apart on the second.
The goal is to study the questions that build transferable reasoning and to spot the pure trivia, so you can give the trivia five minutes instead of fifty.
How to read this list
Each question below carries two notes.
Signal is what a strong answer tells an interviewer about how you'd perform on the job. Data wrangling speed, debugging instinct, idiomatic style, library fluency, systems thinking. This is the reason the question gets asked, even when the interviewer couldn't articulate it.
Trivia tax is a flag for when a question mostly rewards having seen it before. These questions still get asked, so you should know the answers, but memorizing them teaches you nothing you'd use writing real code. Learn them fast and move on.
To be clear about method: the signal and trivia-tax calls here are editorial judgment from time spent on the interviewing side, not the output of a formal study. Where I cite numbers, they come from named public sources, linked inline. The example questions are drawn from real screens and from suspect AI-assisted cheating, expect more code-reading and fewer blank-page prompts. The skill being tested is genuine comprehension.
Data science and ML-flavored Python questions
For data science and ML roles, Python is the medium and the real questions are about statistics, modeling, and judgment. The interviewer wants to know you can turn a vague problem into clean code and defensible reasoning.
Explain the bias-variance tradeoff.
High bias means the model is too simple and underfits; high variance means it's too complex and overfits to noise. The tradeoff is choosing model complexity so test error is minimized, often with regularization to pull a complex model back.
Signal: foundational. Nearly every DS loop asks some version of this. A strong answer connects it to a concrete decision (why you'd add regularization), not just the textbook definition.
Trivia tax: partial. The definition is rote, but the "how would you act on it" is real.
What's the difference between L1 and L2 regularization?
L1 (Lasso) adds the absolute value of coefficients to the loss, which drives some to exactly zero and performs feature selection. L2 (Ridge) adds squared coefficients, which shrinks all of them smoothly without zeroing them out.
Signal: whether you understand the geometric reason L1 produces sparsity, not just that it does. The follow-up "why does L1 zero things out and L2 doesn't" separates memorizers from understanders.
How do you handle an imbalanced dataset?
Resampling (oversampling the minority, undersampling the majority, or SMOTE), class weights in the model, and crucially the right metric: accuracy is useless on a 99/1 split, so use precision, recall, F1, or AUC. The best answer starts with "what's the business cost of each error type."
Signal: high. This question rewards judgment over recipe. Candidates who jump straight to SMOTE without asking about the cost of false negatives are missing the point.
Explain precision versus recall and when you'd optimize for each.
Precision is the fraction of positive predictions that are correct; recall is the fraction of actual positives you caught. Optimize precision when false positives are costly (spam filtering), recall when false negatives are costly (cancer screening).
Signal: high. The concrete examples are what matter. A candidate who can map precision and recall onto a real decision understands the metrics; one who only recites the formulas usually doesn't.
How does gradient descent work, and what's the difference between batch, mini-batch, and stochastic?
Gradient descent walks the parameters downhill along the loss gradient, scaled by a learning rate. Batch uses the whole dataset per step (stable, slow), stochastic uses one example (noisy, fast), mini-batch splits the difference and is the standard in practice.
Signal: whether you understand the speed-versus-stability tradeoff and the role of the learning rate. The learning-rate sensitivity is the part that shows real training experience.
How does a random forest work and when would you choose it?
It's an ensemble of decision trees trained on bootstrapped samples with random feature subsets, averaging their predictions to reduce variance. Choose it when you want a strong baseline with little tuning and some feature-importance insight, on tabular data.
Signal: moderate. Knowing the mechanism is table stakes; the "when would you choose it over gradient boosting" follow-up is where real modeling judgment shows.
Explain backpropagation in simple terms.
A forward pass computes the prediction and loss; the backward pass uses the chain rule to compute how much each weight contributed to the loss, and the weights update in the direction that reduces it. It's the chain rule applied systematically across layers.
Signal: high for ML roles. The chain-rule framing is the discriminator. Candidates who can explain it without hand-waving understand what their framework is doing under
loss.backward().
You're given a messy dataset and asked to predict X. Walk me through your approach.
The strong answer is a process, not an algorithm: understand the target and the business question, explore and clean the data, establish a simple baseline, then iterate with better features and models while validating honestly. Mentioning a baseline first is the senior tell.
Signal: very high, and the most realistic question in any DS loop. It maps directly to the actual job. Candidates who jump to "I'd train XGBoost" without mentioning a baseline or validation are showing inexperience.
How would you design an A/B test, and how do you know when to stop it?
Define the metric and minimum detectable effect, compute the sample size for adequate power before you start, randomize properly, then run until you hit that sample size rather than peeking and stopping at the first significant result. Peeking inflates false positives.
Signal: high for product DS roles. The "don't peek" insight is the one that separates people who've actually run experiments from those who've only read about p-values.
What are word embeddings and why are they useful?
They map words to dense vectors where semantic similarity becomes geometric closeness, so "king" and "queen" sit near each other and analogies fall out of vector arithmetic. They let models transfer learned meaning instead of treating words as opaque IDs.
Signal: moderate for NLP-flavored roles. With LLMs now dominant, the more current follow-up is how embeddings relate to what a transformer learns, which tests whether you've kept up.
What to drill if your interview is in less than 7 days
You don't have time for all of this. Spend it where the signal density is highest.
Core idioms that carry signal: decorators, generators, the mutable-default bug, list comprehensions, and the time complexity of dict, set, and list operations. These show up constantly and reveal fluency fast.
Two algorithm patterns: sliding window and graph traversal (DFS and BFS). They cover a large share of medium questions and transfer across problems.
One debugging rep per day: take a slow or broken snippet and fix it out loud. Profiling before optimizing and reading a traceback calmly are the highest-return skills you can build in a week.
For data roles: Pandasloc/ilocand theSettingWithCopyWarning, vectorization versusapply, missing-data judgment, and precision and recall mapped to a real decision.
Skip the pure trivia:if __name__ == "__main__", reversing a string, reciting*argsand**kwargs. Know the one-line answers, spend nothing more.
How to practice so the answer comes out clean under pressure
Reading answers builds recognition. It does not build the ability to produce a clean answer while someone watches and the clock runs. Those are different skills, and the gap between knowing your answer and delivering it under pressure is where good candidates lose offers.
The fix is to practice out loud, under something like real conditions. Explain your reasoning as you go, because interviewers score your thinking as much as your code, and because narrating your approach is exactly what the rise in AI-cheating suspicion has made interviewers want to hear. Solve a problem you haven't seen, talk through the tradeoffs, and get feedback on where your explanation went fuzzy.
That's the gap Four-Leaf's voice mock interviews are built to close. You practice answering real questions out loud, get scored on substance and delivery, and drill the spots where you freeze, so the answer comes out clean when it counts. You can generate fresh Python questions by role and difficulty and run a full mock before your real one. The questions in this guide are a map of what gets tested. Practicing them out loud is how you turn the map into an offer.
↗ Original-Artikel auf dev.to lesenVollständiger Original-BerichtAusführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
Python interview questions: what each one actually predicts on the job (2026)
- ▸ Why most Python question lists waste your prep time
- ▸ How to read this list
- ▸ Core language and idioms
- ↳ What's the difference between a list and a tuple, and when would you use each?
- ↳ What does a list comprehension do, and when should you not use one?
- ↳ Explain *args and **kwargs.
- ↳ What is a decorator? Write one.
- ↳ What's the difference between is and ==?
- ↳ How does Python handle default mutable arguments?
- ↳ What are generators and why use them?
- ↳ Explain how Python's GIL affects multithreading.
- ↳ What's the difference between @staticmethod, @classmethod, and an instance method?
- ↳ What does if __name__ == "__main__": do?
- ↳ What's the difference between shallow copy and deep copy?
- ▸ Data structures and algorithms in Python
- ↳ Sum all numbers in a nested list of arbitrary depth.
- ↳ Check whether a string's characters can be rearranged into a palindrome.
- ↳ Find the minimum window in a string that contains all characters of a target string.
- ↳ Implement an LRU cache with O(1) get and put.
- ↳ Implement a topological sort.
- ↳ Count the number of islands in a 2D grid.
- ↳ How would you remove duplicates from a list while preserving order?
- ↳ What's the time complexity of common Python operations?
- ↳ Given a stream of numbers, return the k largest at any point.
- ▸ Libraries that actually come up
- ↳ In Pandas, what's the difference between loc and iloc?
- ↳ Why is vectorized NumPy or Pandas code faster than a Python loop?
- ↳ When would you use apply versus a vectorized operation in Pandas?
- ↳ How do you handle missing data in Pandas?
- ↳ What's a NumPy broadcasting rule?
- ↳ Explain async/await and when it helps.
- ↳ What does the requests library do, and how do you handle a failed request?
- ↳ How do you write a test in pytest?
- ↳ What's a context manager and why use one?
- ↳ How do you read a large file that doesn't fit in memory?
- ▸ Debugging and code-reading questions interviewers actually use
- ↳ Here's a function that's slow. Make it faster.
- ↳ This code throws a KeyError intermittently. How do you debug it?
- ↳ What's wrong with this code?
- ↳ Read this comprehension out loud and tell me what it does.
- ↳ This test passes locally but fails in CI. What do you check?
- ↳ Walk me through what happens when this code runs.
- ▸ Data science and ML-flavored Python questions
- ↳ Explain the bias-variance tradeoff.
- ↳ What's the difference between L1 and L2 regularization?
- ↳ How do you handle an imbalanced dataset?
- ↳ Explain precision versus recall and when you'd optimize for each.
- ↳ How does gradient descent work, and what's the difference between batch, mini-batch, and stochastic?
- ↳ How does a random forest work and when would you choose it?
- ↳ Explain backpropagation in simple terms.
- ↳ You're given a messy dataset and asked to predict X. Walk me through your approach.
- ↳ How would you design an A/B test, and how do you know when to stop it?
- ↳ What are word embeddings and why are they useful?
- ▸ What to drill if your interview is in less than 7 days
- ▸ How to practice so the answer comes out clean under pressure
SOCIAL SHARE CARD GENERATOR