Data Science A/B Testing Interview Questions: Experimentation Practice Quiz
Reviewed by Mark Dickie · Last updated
4 questions on this page you can answer and see marked on the spot. Go to the first one
Experimentation in data science is the practice of randomly assigning users to variants and measuring whether a change moves a target metric. Interviewers expect you to design a test end to end: pick a primary metric, size the sample, run the test, and read the result without fooling yourself. Most questions turn on three things: statistical power, the peeking problem, and what to do when several metrics move at once. Expect a whiteboard calculation and a judgment call about a messy result.
Which A/B testing topics come up most in data science interviews?
| Topic | What the interviewer checks | Common mistake |
|---|---|---|
| Sample size and power | Can you compute the per-arm n from a baseline rate and the smallest lift worth shipping? | Sizing for the effect you hope to see, not the smallest one that justifies a launch |
| Peeking and early stopping | Do you know a fixed-horizon p-value is invalid if you check it every day? | Stopping the first time p dips under the threshold |
| Sample ratio mismatch | Do you test whether a 50/50 split actually came out 50/50? | Trusting a lift when assignment counts are skewed |
| Multiple comparisons | Do you correct when one test reads ten metrics? | Reporting the one metric that happened to win |
| CUPED variance reduction | Can you use a pre-experiment covariate to shrink variance? | Adjusting with a covariate measured after treatment began |
| Novelty effects | Would the lift survive once users stop noticing the change? | Reading a week-one spike as a durable win |
How do you work through an A/B test question step by step?
- Write the hypothesis, the primary metric, and the guardrail metrics before any data comes in.
- Work out the sample size per arm from the baseline rate and the smallest lift worth shipping.
- Check the assignment counts for sample ratio mismatch before you look at any outcome.
- Compute the difference in conversion with a confidence interval, not just a p-value.
- Say what you would ship, hold, or rerun, and why.
Key facts
- Tarmac has 15 Data Science interview questions on this topic, 10 of them on this page, at difficulty 1–4 of 5.
- Tarmac tracked 1,276 job postings asking for Data Science in November 2026.
- Roles asking for Data Science advertise a median base salary of US$164,125, across 423 job postings as of November 2026.
- Tarmac last reviewed these Data Science interview questions on 16 November 2026.
At a glance
| Questions | 10 shown · 15 in the bank |
|---|---|
| Difficulty | 1–4 of 5 |
| Formats | Multiple choice, Multiple answer, Code output, True / false, Find the bug, Short answer, Fill in the blank, Flashcard, Coding exercise |
| Interactive | 1 run your code against tests, in the app |
What you'll review
- ab test design
Practice questions
Try one before you open the answer. Pick an option and press Check; it's marked on the spot.
In an A/B test, what is the primary purpose of randomly assigning users to the control group and the treatment group?#
Options
Show answer
Random assignment in an A/B test ensures that the control and treatment groups are, on average, similar in both observed and unobserved characteristics. This balance lets you attribute any statistically significant difference in outcomes to the treatment rather than to pre-existing differences between groups.
Random assignment is the cornerstone of causal inference in experimentation. By randomly assigning users to control and treatment, both observed and unobserved confounders are distributed roughly equally across groups. This means any statistically significant difference in the measured outcome can be attributed to the treatment itself rather than to pre-existing differences between groups. It does not guarantee a positive effect, does not inherently reduce required sample size, and does not remove the need to measure outcomes.
You are designing an A/B test for a checkout button change. Which of the following are sound design practices? Select all that apply.#
Options
Pick every one that applies.
Show answer
Fixing the primary metric and minimum detectable effect in advance, randomizing users into control and treatment, and computing sample size from baseline rate, effect size, significance level, and power are sound A/B test design practices. Stopping the moment a p-value dips below 0.05 without correction, or assigning users by expected spend, undermines the validity of the result.
Pre-registering the primary metric and minimum detectable effect keeps the analysis from being tuned after the fact, and random assignment makes the groups comparable in expectation so differences can be attributed to the change. Sample size is derived from the baseline rate, the minimum detectable effect, the significance level, and power. Repeatedly peeking at a p-value and stopping at the first dip below 0.05 without correction inflates the false positive rate well above 5%. Assigning users by expected spend introduces selection bias, because the groups are no longer randomized and any difference may reflect the assignment rule rather than the treatment.
An A/B test assigned 1,000 users to control and 1,000 users to treatment. Control had 120 conversions and treatment had 150. What exactly does this Python snippet print?#
control_users = 1000
control_conv = 120
treatment_users = 1000
treatment_conv = 150
rate_c = control_conv / control_users
rate_t = treatment_conv / treatment_users
print(f"{rate_t - rate_c:.1%}")Show answer
3.0%
The control conversion rate is 120/1000 = 0.12 and the treatment rate is 150/1000 = 0.15. The f-string computes the absolute difference (treatment minus control), about 0.03, and the format spec .1% multiplies by 100 and shows one decimal place, giving 3.0%. This is the absolute lift in percentage points, not the relative lift (which would be 25%).
In A/B test design, suppose you decrease the minimum detectable effect (MDE) — the smallest true effect you want to reliably detect — while holding the significance level (α) and statistical power (1−β) constant. What happens to the required sample size per variant?#
Options
Show answer
Decreasing the minimum detectable effect (MDE) while holding significance level and power constant increases the required sample size per variant. Required sample size scales roughly as 1/Δ², so a smaller detectable difference demands more data to separate the true effect from random noise.
Sample size for a two-proportion z-test scales inversely with the square of the effect size: n ∝ 1/Δ². When you shrink the MDE (Δ) while keeping α and power fixed, you are asking the test to detect a smaller difference, which requires more data to distinguish from noise. Therefore the required sample size per variant increases.
In a two-sample A/B test on a continuous metric, suppose alpha, power, and outcome variance are held fixed. True or false: to halve the minimum detectable effect, you need roughly four times as many users per group.#
Options
Show answer
True. Per-group sample size in a two-sample test scales with the inverse square of the minimum detectable effect. With alpha, power, and outcome variance fixed, sample size is proportional to 1/δ², so halving the effect size requires roughly four times as many users in each group.
For a two-sample comparison of means, the approximate per-group sample size is n = 2 * (z_{1-alpha/2} + z_{power})^2 * sigma^2 / delta^2, where delta is the minimum detectable effect. Since n is proportional to 1/delta^2, halving delta multiplies n by 2^2 = 4. The statement is therefore true under the standard normal approximation with alpha, power, and variance fixed.
This function is meant to assign each user to a stable A/B test variant (50% control, 50% treatment) for the experiment experiment_name. Identify the line that introduces the bug in the experiment-assignment logic.#
import random
def assign_variant(user_id: str, experiment_name: str) -> str:
# 50/50 split for the experiment
if random.random() < 0.5:
return "treatment"
return "control"Show answer
The bug is on line 5.
Line 5 draws a fresh random number on every call, so the variant does not depend on the user at all. The same user can be shown control on one page load and treatment on the next, which contaminates the experiment and violates the requirement that assignment be consistent per user. The fix is to make the assignment a deterministic function of the user and experiment, for example by hashing experiment_name plus user_id and splitting on the hash value. The other lines are fine: the import, the signature, and the return statements do not themselves break the split.
You are planning a two-sided A/B test on a checkout conversion rate with a baseline of 10%. (1) Name the four inputs you must fix before computing the per-variant sample size. (2) State roughly how the required sample size per variant changes if the minimum detectable effect is halved while everything else stays the same. Answer in two to four sentences.#
Show answer
The four inputs are the baseline conversion rate (10%), the minimum detectable effect (the smallest absolute or relative lift worth detecting), the significance level alpha (for example 0.05, two-sided), and the statistical power (for example 80%). Halving the minimum detectable effect roughly quadruples the required sample size per variant, because the required n scales with the inverse square of the effect size.
A standard two-proportion sample size calculation needs the baseline rate, the minimum detectable effect, the significance level (alpha), and the desired power; these four jointly determine n per arm. For a fixed alpha and power, n is approximately proportional to (z_alpha + z_beta)^2 times the variance term divided by the square of the effect size, so n scales with 1/delta^2. Halving delta therefore multiplies n by about 4, which is why detecting smaller lifts is expensive and why the MDE should be chosen from business value rather than set arbitrarily small.
In an A/B test, the probability of rejecting the null hypothesis when a true effect of the minimum size you care about exists is called statistical _____. Holding the significance level and that power fixed, detecting a smaller minimum detectable effect requires a _____ sample size per variant.#
Show answer
In an A/B test, the probability of rejecting the null hypothesis when a true effect of the minimum size you care about exists is called statistical power. Holding the significance level and that power fixed, detecting a smaller minimum detectable effect requires a larger sample size per variant.
Statistical power is the probability of correctly rejecting the null hypothesis when a real effect exists, so it is the complement of the Type II error rate. For a fixed alpha and fixed power, the required sample size scales with the inverse square of the effect size, so halving the minimum detectable effect roughly quadruples the sample needed per variant. Therefore detecting a smaller effect requires a larger sample size.
An A/B test compares two variants on a binary conversion metric with a baseline rate of 10%, using a two-sided two-proportion z-test. Name the three design inputs (besides the baseline rate itself) that determine the required sample size per arm, and state the direction each one moves the sample size when it is increased.#
Show answer
- Significance level alpha (the false-positive rate): raising alpha lowers the required sample size (the critical z-value shrinks as alpha grows). 2) Statistical power (1 minus the false-negative rate): raising power increases the required sample size. 3) Minimum detectable effect (MDE), the smallest absolute or relative lift you want to reliably detect: raising the MDE lowers the required sample size, and because n scales roughly with 1/MDE^2, doubling the MDE roughly quarters n while halving the MDE roughly quadruples n.
The per-arm sample size for a two-proportion z-test is approximately n = (z_{1-alpha/2} + z_power)^2 * [p1(1-p1) + p2(1-p2)] / (p2 - p1)^2. The critical value z_{1-alpha/2} shrinks as alpha grows, so increasing alpha lowers n. z_power grows as power rises, so increasing power raises n. The denominator (p2 - p1)^2 is the squared effect size, so increasing the MDE enlarges the denominator and deflates n roughly with the inverse square of the effect. The baseline rate also enters the variance term, but the question asks for the design levers, which are alpha, power and MDE.
You are planning an A/B test on a conversion metric. Write required_sample_per_arm(baseline_pct, mde_pct) that returns the minimum number of users needed in EACH arm, using Lehr's rule of thumb for a two-sided test at alpha = 0.05 and 80% power:#
Starter code
def required_sample_per_arm(baseline_pct, mde_pct):
# TODO: apply Lehr's rule n = 16*p*(1-p)/delta^2 per arm, rounded up to an integer
return 16 * baseline_pct * (100 - baseline_pct) / (mde_pct ** 2)
Your solution must pass
- baseline 10%, MDE 2pp gives 3600 exactly
- baseline 50%, MDE 5pp gives 1600
This one is written and run, not read. Solve it in the app and your code is executed against these tests and the hidden ones.
Related interview questions
Job market
See data-science salaries and hiring demand from live job postings.
The other 5 questions
This page shows 10 and marks what you pick. That's as far as a page can go. A free account opens the other 5 and keeps every answer. What you miss comes back until it's right: after a day, then at longer gaps.
Free · the whole bank · 100 answers per 30 days, each marked with written feedback