Data Scientist Top 100 Interview Questions
100 data scientist interview questions with structured answers, comparison tables, flow diagrams, worked calculations and runnable Python and SQL. Covers statistics, probability, A/B testing, causal inference, product metrics, SQL analytics, exploratory analysis, modeling for decisions and communication, from the basics to real business scenarios.
Questions 1-20 of 100
Q1.What does a data scientist own, from a business question to a decision?
A data scientist turns ambiguous questions into evidence that changes a decision. Writing models or queries is only part of the job; the value comes from choosing the right question, measuring it honestly and explaining what the result means.
- Framing: agree on the decision the analysis will inform, the metric that defines success and the deadline that matters.
- Data understanding: find where the data comes from, how it is logged and what it silently leaves out.
- Analysis or modeling: pick the simplest method that answers the question, from a well-made chart to an experiment or a predictive model.
- Validation: check results against known totals, test sensitivity to assumptions and look for confounders.
- Communication: state the answer, its uncertainty and the recommended action in the audience's language.
- Follow-through: track whether the decision worked, and turn repeated analyses into dashboards or automated reports.
Strong data scientists also say no to analyses that cannot change any decision, and they flag data problems instead of working around them quietly.
Q2.How do you turn a vague business question into an analysis plan?
Start from the decision, not the data. A question such as "why are sales down?" becomes workable once you know who will act on the answer, what actions are possible and how precise the answer must be.
flowchart TD A["Vague question from a stakeholder"] --> B["Identify the decision and its owner"] B --> C["Define the metric and the comparison"] C --> D["List hypotheses that would change the decision"] D --> E["Check which data can test each hypothesis"] E --> F["Agree on scope, method and deadline"] F --> G["Analyze and share early findings"]Questions to ask early:
- What will you do differently depending on the answer?
- Compared with what: last month, last year, a forecast or a control group?
- Which segments, time periods and definitions are in scope?
- How confident must the answer be, and by when?
Write the plan down in a few lines and confirm it with the stakeholder. A short written plan prevents the most common failure: a careful answer to a question nobody asked.
Q3.How do descriptive, diagnostic, predictive and prescriptive analytics differ?
They answer progressively harder questions, from what happened to what should be done. Each level needs the levels below it to be trustworthy.
Descriptive Diagnostic Predictive Prescriptive What happened? Why did it happen? What is likely to happen? What should we do? Dashboards, summaries and trends Segment breakdowns, drill-downs and causal analysis Forecasts and classification models Optimization, simulation and experiment-backed decisions Weekly orders fell 8% The drop is concentrated in one region after a price change Next month's orders will be 5% below plan Reverse the price change in that region and test a smaller one How to use the distinction:
- Most business requests start descriptive; do that part well, because errors there flow into everything above it.
- Diagnostic work needs comparisons and segment splits, and it often uncovers data quality issues.
- Predictive work is useful only when someone can act on the prediction in time.
- Prescriptive work usually requires an experiment or a strong causal argument, since correlation alone cannot say what an action will change.
Q4.How do simple random, stratified, cluster and systematic sampling differ?
They differ in how units are chosen, which changes cost, precision and the risk of bias. The right choice depends on how the population is organized and which groups you need to measure well.
Simple random Stratified Cluster Systematic Every unit has the same chance of selection Sample separately within groups such as regions or plans Randomly pick whole groups, such as stores, then study everyone in them Pick every k-th unit from a list after a random start Simple and unbiased, but small groups may be missed More precise, and guarantees enough data for each group Cheaper to collect, but less precise when groups differ Easy to run, but biased if the list has a repeating pattern Practical guidance:
- Use stratified sampling when you must report results for small segments, then weight results back to the population's mix.
- Use cluster sampling when reaching individuals is expensive, and account for the larger variance in the analysis.
- Check how the sampling frame was built, since a sample is only as good as the list it was drawn from.
Sampling bias, such as surveying only active users, cannot be fixed by a larger sample.
Q5.How do the mean, median and mode behave when data is skewed?
The mean uses every value, so a few extreme values pull it toward the long tail. The median is the middle value and ignores how extreme the tail is. The mode is the most frequent value, which is most useful for categories or heavily repeated values.
- Symmetric data: all three are close, and the mean is the most efficient summary.
- Right-skewed data, such as income, order value or session length: the mean sits above the median, often far above.
- Reporting: show the median for typical experience, and the mean when totals matter, because the mean times the count gives the total.
When each is the right choice:
- Revenue planning needs the mean, since a few large orders really do add revenue.
- "What does a typical customer spend?" needs the median.
- Product configuration questions, such as the most chosen plan, need the mode.
Always report the spread or a percentile next to a central value, since two groups with the same median can behave very differently.
Example
Seven employees earn 30, 32, 35, 35, 38, 40 and 250 thousand per year.
- Mean:
(30 + 32 + 35 + 35 + 38 + 40 + 250) / 7 = 460 / 7 ≈ 65.7thousand. - Median: the fourth value in sorted order, 35 thousand.
- Mode: 35 thousand, which appears twice.
- One high salary lifts the mean almost twice as high as the median, so "average salary is 65.7 thousand" misrepresents what most employees earn.
Q6.How do the variance, standard deviation and interquartile range describe spread?
They measure how far values typically sit from the center, but they respond differently to outliers.
- Variance: the average squared distance from the mean. Squaring makes its units awkward, such as squared rupees, but it adds neatly across independent sources, which is why statistical formulas use it.
- Standard deviation: the square root of the variance, in the original units. For roughly normal data, about 68% of values lie within one standard deviation of the mean and about 95% within two.
- Interquartile range: the distance between the 25th and 75th percentiles. It describes the middle half of the data and ignores the tails completely.
Which one to use:
- Use the standard deviation for roughly symmetric data and as an input to tests and confidence intervals.
- Use the interquartile range, or a set of percentiles, for skewed data such as latency or spending.
- Divide by
n - 1for a sample standard deviation, which corrects the tendency of a sample to understate the population's spread.
One extreme value can inflate the standard deviation dramatically while barely moving the interquartile range.
Example
One slow request among seven inflates the standard deviation but barely moves the interquartile range.
import statistics times_ms = [120, 130, 135, 140, 150, 160, 900] q1, _, q3 = statistics.quantiles(times_ms, n=4) print(round(statistics.mean(times_ms), 1)) # 247.9 print(statistics.median(times_ms)) # 140 print(round(statistics.stdev(times_ms), 1)) # 287.9 print(q1, q3, q3 - q1) # 130.0 160.0 30.0Q7.What does the central limit theorem say, and why does it matter in practice?
It says that the average of many independent observations has an approximately normal distribution, whatever the shape of the original data, as long as the data has a finite variance and the sample is large enough. The spread of that average shrinks with the square root of the sample size.
Why it matters:
- Confidence intervals and tests: you can use normal-based formulas for means and proportions even when individual values are skewed, such as order values.
- A/B tests: conversion rates and average revenue per user are averages, so their differences are approximately normal with enough users.
- Precision planning: to halve the uncertainty of an average, you need four times as much data.
Where it breaks down:
- Small samples from very skewed data, such as a few hundred users when a handful of them spend thousands.
- Heavy-tailed data with no finite variance, where averages never settle.
- Dependent observations, such as many sessions from the same user, which carry less information than their count suggests.
For heavy skew or small samples, use larger samples, transformations or bootstrap intervals rather than trusting the normal approximation blindly.
Q8.What is the difference between a standard deviation and a standard error?
The standard deviation describes how much individual values vary. The standard error describes how much an estimate, such as a sample mean, would vary if you repeated the sampling. Mixing them up makes results look far more or far less certain than they are.
Standard deviation Standard error Spread of individual observations Uncertainty of an estimate such as a mean or a rate Stays roughly the same as the sample grows Shrinks as the sample grows, by the square root of nAnswers "how different are customers from each other?" Answers "how precisely do we know the average?" Formulas:
- Standard error of a mean:
SE = s / √n, wheresis the sample standard deviation. - Standard error of a proportion:
SE = √(p × (1 − p) / n).
Error bars on a chart should say which one they show; error bars based on the standard deviation answer a different question from confidence intervals based on the standard error.
Example
A sample of 400 orders has a mean value of 1,200 rupees and a standard deviation of 500 rupees.
- Standard error:
500 / √400 = 500 / 20 = 25rupees. - Individual orders typically differ from the mean by about 500 rupees.
- The sample mean itself is uncertain by only about 25 rupees.
- A 95% confidence interval for the mean is about
1,200 ± 1.96 × 25, which is 1,151 to 1,249 rupees.
- Standard error of a mean:
Q9.How do you calculate a confidence interval for a conversion rate, and how should you interpret it?
For a proportion with a reasonably large sample, the 95% interval is the observed rate plus or minus 1.96 standard errors. It gives a range of plausible values for the true rate, based on the data and the method's assumptions.
SE = √(p × (1 − p) / n)interval = p ± 1.96 × SE
Correct interpretation: if you repeated the sampling many times, about 95% of the intervals built this way would contain the true rate. It is not a 95% probability that this particular interval contains it, though in practice people use it as a range of plausible values.
Practical points:
- Wider intervals mean less information; report them rather than a bare point estimate.
- For small samples or rates near 0% or 100%, the simple formula can produce impossible values below zero, so use an interval method designed for proportions, or a bootstrap.
- When two intervals overlap slightly, the difference can still be significant; test the difference directly instead of comparing intervals by eye.
Example
A landing page converts 300 of 2,500 visitors, a rate of 12%.
p × (1 − p) = 0.12 × 0.88 = 0.1056SE = √(0.1056 / 2,500) = √0.00004224 ≈ 0.0065- Margin:
1.96 × 0.0065 ≈ 0.0127, about 1.3 percentage points. - The 95% interval is roughly 10.7% to 13.3%, so a claim that the page converts "around 12%" is accurate to within about one point either way.
Q10.What does a p-value mean, and what does it not mean?
A p-value is the probability of seeing a result at least as extreme as the one observed, assuming the null hypothesis is true and the test's assumptions hold. A small p-value means the data would be surprising if there were no real effect.
What it does not mean:
- It is not the probability that the null hypothesis is true.
- It is not the probability that the result happened "by chance".
- It does not measure the size or importance of an effect; a tiny effect with huge samples gives a tiny p-value.
- A p-value above 0.05 does not prove there is no effect; the test may simply lack power.
Using it well:
- Fix the significance level and the analysis before looking at the data.
- Report the effect size and its confidence interval alongside the p-value.
- Account for multiple comparisons when testing many metrics or segments.
- Treat 0.05 as a convention for decisions, not a boundary between true and false.
Interview tip: interviewers often ask candidates to explain a p-value to a product manager. A sentence such as "if the change did nothing, we would see a gap this large only about 2% of the time" is accurate and easy to follow.
Q11.How do type I and type II errors trade off in hypothesis testing?
A type I error is acting on an effect that does not exist; a type II error is missing an effect that does. For a fixed sample size, lowering one raises the other, so the balance should reflect what each mistake costs the business.
Type I error Type II error False positive: rejecting a true null hypothesis False negative: failing to reject a false null hypothesis Probability set by the significance level, often 5% Probability is one minus power, often 20% Cost: shipping a change that does nothing or harms users Cost: abandoning a change that would have helped How to set the balance:
- When a false launch is expensive or hard to reverse, such as a pricing change, use a stricter significance level.
- When missing a win is costlier and rollback is easy, such as a button color, accept a looser level or a smaller test.
- To reduce both errors at once, increase the sample size or reduce noise in the metric.
Writing the expected cost of each error down before the test makes the threshold a business decision rather than a habit.
Q12.What is statistical power, and what determines it?
Power is the probability that a test detects an effect of a given size when that effect really exists. A common target is 80%, which still means one real effect in five goes undetected.
What raises power:
- Larger effects: big changes are easier to detect than small ones.
- Larger samples: the standard error shrinks with the square root of the sample size.
- Less noise: metrics with lower variance, or variance reduction using pre-experiment data, make the same effect clearer.
- A looser significance level: raising it from 1% to 5% increases power but also raises false positives.
- One-sided tests: more power in the expected direction, at the cost of not detecting harm properly.
Why it matters:
- An underpowered test that shows no significant result tells you almost nothing, and it encourages wrong conclusions such as "the feature has no effect".
- Underpowered tests that do reach significance tend to exaggerate the effect size, because only lucky, inflated estimates cross the threshold.
Calculate the required sample size before running a test, and if it is unreachable, choose a more sensitive metric, a bigger change or a different method.
Q13.How do one-tailed and two-tailed tests differ, and which should you use?
A two-tailed test looks for a difference in either direction; a one-tailed test looks only in one direction chosen in advance. The one-tailed test gains power in its chosen direction but cannot detect an effect in the other.
One-tailed test Two-tailed test Asks "is the new version better?" Asks "is the new version different?" All of the 5% significance level sits in one tail The 5% is split, 2.5% in each tail Needs fewer users for the same power in the chosen direction Detects both improvements and harm Risky when harm matters, because harm is never tested The safe default for most product experiments Guidance:
- Use a two-tailed test by default, since a change that hurts users is as important to detect as one that helps.
- A one-tailed test is acceptable for non-inferiority questions, such as "is the cheaper process not worse by more than 1 point?", when the direction is genuinely fixed beforehand.
- Never switch from two-tailed to one-tailed after seeing the data; that halves the p-value dishonestly.
Q14.How do you choose between a t-test, a chi-square test and a rank-based test?
Choose by the type of outcome and by how well the data fits each test's assumptions.
t-test Chi-square test Rank-based test Compares means of a continuous metric between two groups Compares counts or proportions across categories Compares whole distributions using ranks instead of values Best for average order value or time on task with decent samples Best for conversion, plan choice or any yes-or-no outcome Best for small samples, ordinal ratings or heavy outliers Assumes roughly normal sample means and independent observations Assumes independent observations and enough expected counts per cell Assumes independent observations, and tests a shift in distribution rather than means Practical notes:
- With large samples, the t-test is robust to skew because sample means become approximately normal; the version that does not assume equal variances is the safer default.
- For very small cell counts, use an exact test for proportions instead of the chi-square approximation.
- A rank-based test answers a slightly different question, so do not report its result as a difference in means.
- If observations are not independent, such as several sessions per user, none of these tests is valid without aggregating to the independent unit first.
Q15.What is the difference between independent events and mutually exclusive events?
Independent events do not affect each other's probability. Mutually exclusive events cannot happen together. The two ideas are easily confused, yet they are almost opposites: two mutually exclusive events with non-zero probabilities are always dependent, because knowing one happened tells you the other did not.
Independent events Mutually exclusive events P(A and B) = P(A) × P(B)P(A and B) = 0P(A or B) = P(A) + P(B) − P(A) × P(B)P(A or B) = P(A) + P(B)A user clicking an ad, and an unrelated user clicking it A single order shipped by air or by road Why it matters in analysis:
- Multiplying probabilities is only valid for independent events; in user data, behaviors are often correlated, so multiplied estimates are wrong.
- Adding probabilities is only valid for mutually exclusive events; otherwise overlaps are counted twice.
- Funnel math that multiplies step rates assumes each step's rate does not depend on how users arrived, which is worth checking.
Example
Two events have
P(A) = 0.3andP(B) = 0.4.- If they are independent:
P(A and B) = 0.3 × 0.4 = 0.12, andP(A or B) = 0.3 + 0.4 − 0.12 = 0.58. - If they are mutually exclusive:
P(A and B) = 0, andP(A or B) = 0.3 + 0.4 = 0.7. - The same two probabilities give different answers, so the relationship between events must be known before combining them.
Q16.Which probability distributions come up most often in data science, and when do they apply?
Knowing the common distributions helps you choose sensible tests and models and spot data that does not fit them.
Normal Binomial Exponential Log-normal Symmetric bell shape described by a mean and a standard deviation Number of successes in a fixed number of independent yes-or-no trials Waiting time between independent random events at a constant rate Positive values whose logarithm is normal, with a long right tail Measurement errors, heights and sample means Conversions among visitors, defects among items Time between support tickets or arrivals Order values, incomes and session lengths Other shapes to recognize:
- Counts of rare events per interval, such as orders per minute, follow a count distribution whose variance equals its mean; when the variance is much larger, the data is overdispersed and needs a more flexible model.
- Heavy-tailed data, such as followers per account, where a few values dominate totals and averages are unstable.
- Bimodal data, two peaks that usually reveal two different populations mixed together.
Plot the data before assuming a distribution, and check whether a transformation such as the logarithm makes it easier to work with.
Q17.How do you calculate expected value, and how do you use it in business decisions?
Expected value is the probability-weighted average of all possible outcomes: multiply each outcome's value by its probability and add the results. It shows what a decision is worth on average if it were repeated many times.
EV = Σ (probability of outcome × value of outcome)How to use it:
- Compare options, such as whether to send a discount, by their expected value per customer.
- Include costs as negative outcomes, so the comparison reflects net value.
- Use the right probabilities: for a retention offer, what matters is how many customers stay because of the offer, not how many accept it.
Limits:
- Expected value ignores risk; two options with the same average can have very different chances of a large loss, so show the range of outcomes too.
- Probabilities are estimates, so test how sensitive the decision is to them.
- Rare, extreme outcomes can dominate the average and deserve explicit discussion.
Example
A retention offer costs 200 rupees per customer contacted. Experiments show it prevents churn for 6% of contacted customers, and a retained customer is worth 4,000 rupees in future margin.
- Expected benefit per contact:
0.06 × 4,000 = 240rupees. - Expected value per contact:
240 − 200 = 40rupees. - Contacting 10,000 customers is worth about
10,000 × 40 = 400,000rupees. - If the true prevention rate were 4% instead of 6%, the value would be
0.04 × 4,000 − 200 = −40rupees per contact, so the decision depends heavily on measuring that rate well.
Q18.Why does correlation not imply causation, and what usually explains a misleading correlation?
Two variables can move together without one causing the other. Before acting on a correlation, look for the explanations that produce it without any causal link.
flowchart LR A["Underlying engagement"] --> B["Turns on notifications"] A --> C["Stays active longer"] B -.->|"Observed correlation"| C- Confounding: a third factor drives both. Highly engaged users both enable notifications and stay longer, so forcing notifications on everyone may not improve retention.
- Reverse causation: the outcome drives the supposed cause, such as satisfied customers writing more reviews.
- Selection: the data includes only certain cases, such as only customers who completed onboarding.
- Chance: among thousands of metric pairs, some will correlate strongly by luck.
How to get closer to causation:
- Run a randomized experiment when possible.
- Otherwise, use designs that control for confounders, such as comparing similar groups before and after a change.
- Check whether the timing is consistent: the cause must come before the effect.
- Look for a plausible mechanism and test its predictions in other data.
Q19.How do linear correlation and rank correlation differ?
Linear correlation measures how well a straight line fits the relationship between two variables. Rank correlation measures whether one variable consistently rises or falls with the other, whatever the shape, by correlating their ranks instead of their values.
Linear correlation Rank correlation Uses actual values Uses the order of the values Sensitive to outliers and to curved relationships Robust to outliers and captures any steadily increasing or decreasing relationship Best for roughly linear, roughly normal data Best for skewed data, ordinal ratings or curved but monotonic relationships Interpreting either one:
- Values range from −1 to 1; 0 means no relationship of that kind, not no relationship at all, since a U-shaped pattern can give zero.
- Always plot the data, because very different patterns can produce the same coefficient.
- A strong coefficient says nothing about causation or about the size of the effect, only about how consistently the variables move together.
Example
A relationship that rises steadily but not in a straight line has a perfect rank correlation and a weaker linear one.
import statistics ad_spend = [1, 2, 3, 4, 5, 6] signups = [2, 3, 5, 8, 20, 90] print(round(statistics.correlation(ad_spend, signups), 3)) # 0.771 print(statistics.correlation(ad_spend, signups, method="ranked")) # 1.0Q20.How does the law of large numbers mislead analysts when sample sizes differ?
The law of large numbers says that averages settle toward their true value as samples grow. The flip side is that small samples swing widely, so groups with few observations dominate both the top and the bottom of any ranking.
Where this causes wrong conclusions:
- Rankings: the stores, products or sales agents with the highest and lowest conversion rates are often simply the smallest ones.
- Segment drill-downs: a tiny segment showing a 40% jump is usually noise.
- Early experiment results: the first day of a test often shows dramatic effects that fade.
How to avoid it:
- Show sample sizes, or confidence intervals, next to every rate.
- Set a minimum sample size before ranking or flagging groups.
- Shrink small-group estimates toward the overall average, weighting each group's own data by how much of it there is.
- Compare groups using funnel plots, which show how much variation to expect at each sample size.
Example
Two stores have the same true conversion rate of 10%.
- A store with 20 visitors has a standard error of
√(0.1 × 0.9 / 20) ≈ 0.067, so its observed rate commonly lands anywhere from about 0% to 23%. - A store with 2,000 visitors has a standard error of
√(0.1 × 0.9 / 2,000) ≈ 0.0067, so its rate stays between about 8.7% and 11.3%. - The small store will often appear at the top or bottom of a league table purely by chance.