Probability Interview Questions for Data Science

Probability questions reward one habit above all: check your answer two ways. Eight classic and data-based questions are solved here with exact fractions and with simulation, then on 12,330 real shopping sessions, where the binomial answer turned out wrong for a reason worth explaining in an interview.

GloryTecks Team

Training & Placement Faculty

4 January 2026 9 min read

Last updated: 8 October 2026

Share:

Probability questions in data science interviews come in two kinds: puzzles with a neat exact answer, and questions about real data where the assumptions behind the neat answer may not hold. Both reward the same habit: check your answer a second way. These probability interview questions are each solved exactly, with Python's fractions module so that 1/6 stays 1/6 (Python: fractions), then checked by simulation or against 12,330 real sessions from the UCI Online Shoppers dataset (UCI: Online Shoppers).

python
import csv
import random
from fractions import Fraction
from math import comb, prod

rng = random.Random(2026)
N = 200_000

print("P1 birthday problem: 23 people, any shared birthday?")
exact = 1 - prod(Fraction(365 - k, 365) for k in range(23))
sim = sum(len(set(rng.randrange(365) for _ in range(23))) < 23 for _ in range(N)) / N
print(f"   exact {float(exact):.4f} | simulated {sim:.4f}")

print("\nP2 Bayes: 1% have a condition; test sensitivity 99%, specificity 95%. P(condition | positive)?")
exact = Fraction(1, 100) * Fraction(99, 100) / (Fraction(1, 100) * Fraction(99, 100) + Fraction(99, 100) * Fraction(5, 100))
people = [(sick := rng.random() < 0.01, rng.random() < (0.99 if sick else 0.05)) for _ in range(N)]
positives = [sick for sick, positive in people if positive]
print(f"   exact {exact} = {float(exact):.3f} | simulated {sum(positives) / len(positives):.3f} from {len(positives):,} positives")

print("\nP3 Monty Hall: stay or switch?")
wins = {"stay": 0, "switch": 0}
for _ in range(N):
    car, pick = rng.randrange(3), rng.randrange(3)
    opened = next(d for d in range(3) if d not in (car, pick))
    wins["stay"] += pick == car
    wins["switch"] += next(d for d in range(3) if d not in (pick, opened)) == car
print(f"   stay wins {wins['stay'] / N:.3f} | switch wins {wins['switch'] / N:.3f} (exact 1/3 and 2/3)")

print("\nP4 expected rolls of a die until the first six")
def rolls_until_six():
    n = 1
    while rng.randrange(6) != 5:
        n += 1
    return n
print(f"   exact 6 | simulated {sum(rolls_until_six() for _ in range(N)) / N:.3f}")

print("\nP5 coupon collector: expected rolls to see all six faces")
exact = sum(Fraction(6, k) for k in range(1, 7))
def rolls_until_all():
    seen, n = set(), 0
    while len(seen) < 6:
        seen.add(rng.randrange(6))
        n += 1
    return n
print(f"   exact {exact} = {float(exact):.2f} | simulated {sum(rolls_until_all() for _ in range(N)) / N:.2f}")

with open("online_shoppers_intention.csv") as f:              # UCI Online Shoppers Purchasing Intention
    sessions = [(r["Weekend"] == "TRUE", r["Revenue"] == "TRUE") for r in csv.DictReader(f)]
n = len(sessions)
weekend = sum(w for w, _ in sessions) / n
bought = sum(b for _, b in sessions) / n
both = sum(w and b for w, b in sessions) / n

print(f"\nP6 conditional probability is not symmetric ({n:,} real sessions)")
print(f"   P(purchase | weekend) = {both / weekend:.3f} | P(weekend | purchase) = {both / bought:.3f}")

print("\nP7 are weekend and purchase independent?")
print(f"   P(weekend and purchase) = {both:.4f} vs P(weekend) x P(purchase) = {weekend * bought:.4f}")

print("\nP8 at least one buyer among 10 sessions")
exact = 1 - (1 - bought) ** 10
outcomes = [b for _, b in sessions]
groups = [outcomes[i:i + 10] for i in range(0, n - 9, 10)]
print(f"   binomial {exact:.3f} | observed in {len(groups):,} consecutive groups of 10: {sum(any(g) for g in groups) / len(groups):.3f}")
print(f"   exactly 2 buyers: binomial {comb(10, 2) * bought ** 2 * (1 - bought) ** 8:.3f} | observed {sum(sum(g) == 2 for g in groups) / len(groups):.3f}")
shuffled = outcomes[:]
rng.shuffle(shuffled)
groups = [shuffled[i:i + 10] for i in range(0, n - 9, 10)]
print(f"   same sessions in random order: at least one {sum(any(g) for g in groups) / len(groups):.3f} | exactly 2 {sum(sum(g) == 2 for g in groups) / len(groups):.3f}")
text
P1 birthday problem: 23 people, any shared birthday?
   exact 0.5073 | simulated 0.5046

P2 Bayes: 1% have a condition; test sensitivity 99%, specificity 95%. P(condition | positive)?
   exact 1/6 = 0.167 | simulated 0.162 from 11,967 positives

P3 Monty Hall: stay or switch?
   stay wins 0.334 | switch wins 0.666 (exact 1/3 and 2/3)

P4 expected rolls of a die until the first six
   exact 6 | simulated 6.001

P5 coupon collector: expected rolls to see all six faces
   exact 147/10 = 14.70 | simulated 14.70

P6 conditional probability is not symmetric (12,330 real sessions)
   P(purchase | weekend) = 0.174 | P(weekend | purchase) = 0.262

P7 are weekend and purchase independent?
   P(weekend and purchase) = 0.0405 vs P(weekend) x P(purchase) = 0.0360

P8 at least one buyer among 10 sessions
   binomial 0.814 | observed in 1,233 consecutive groups of 10: 0.786
   exactly 2 buyers: binomial 0.281 | observed 0.230
   same sessions in random order: at least one 0.814 | exactly 2 0.273

P1. In a room of 23 people, how likely is a shared birthday?

About 50.7%. Work with the complement: the chance that all 23 birthdays differ is 365/365 × 364/365 × … × 343/365, and one minus that is 0.5073. The simulation gave 0.5046. The surprise, that 23 is enough to pass 50% (Wikipedia: birthday problem), comes from counting pairs: 23 people make 253 pairs. The interview lesson is the method. "At least one" questions are almost always easier through "none".

P2. A test is 99% sensitive and 95% specific, and 1% of people have the condition. If you test positive, how likely are you to have it?

One in six, about 16.7%. Out of 10,000 people, 100 have the condition and 99 of them test positive; of the 9,900 without it, 5% or 495 also test positive. So 99 of 594 positives are real. The simulation of 200,000 people agreed at 16.2%. Ignoring the 1% prevalence and answering "99%" is the base rate fallacy (Wikipedia: base rate fallacy), and it is exactly what the question is designed to catch. The same arithmetic explains why a fraud model with high accuracy can still flag mostly innocent transactions.

Answer with counts, not Bayes' formula: interviewers follow "100 of 10,000" more easily than conditional probability notation.

P3. Monty Hall: should you switch?

Yes. Switching wins two times in three (Wikipedia: Monty Hall problem); the simulation gave 0.666 against 0.334 for staying. The short explanation: your first pick is right one time in three, and switching wins in every case where it was wrong, because the host always opens a losing door from the other two. State that assumption out loud. If the host opened a door at random and happened to show a goat, the answer would change.

P4. How many rolls until the first six, on average?

Six. The number of trials until the first success with probability p is geometric with mean 1/p; the simulation gave 6.001. The same reasoning answers "how many sessions until the first purchase" or "how many calls until a sale".

P5. How many rolls to see all six faces?

147/10, or 14.7 on average, and the simulation gave 14.70. Break it into stages. The first new face takes one roll, the second takes 6/5 on average, the third 6/4, and so on down to 6/1 for the last, which sums to 6 × (1 + 1/2 + … + 1/6). The last few faces take most of the time. That is why rare categories are slow to appear in a sample, and why testing "until every case is covered" can take far longer than expected.

P6. Is P(A | B) the same as P(B | A)?

No, and real data shows how different they are. Among weekend sessions, 17.4% ended in a purchase. Among purchases, 26.2% happened at a weekend. Same data, different questions: the first is about weekend visitors, the second about buyers. Mixing them up is a common mistake in reports, and a classic one in courtrooms.

P7. How do you check whether two events are independent?

Compare P(A and B) with P(A) × P(B). Weekend purchases made up 4.05% of all sessions, while independence would predict 3.60%. So the events are not independent: weekends carry more purchases than chance alone would explain. Whether that gap is larger than random variation is a statistics question; see the companion article on statistics interview questions.

P8. If 15.5% of sessions buy, what is the chance that at least one of ten does?

The binomial answer is 1 − 0.845¹⁰ = 0.814. But in the real file, taking consecutive groups of ten sessions, only 78.6% of groups had a buyer, and the share with exactly two buyers was 23.0% against a predicted 28.1%. When the same sessions were shuffled into random order, the observed values returned to 0.814 and 0.273.

So the formula was not wrong. Its assumption was: the binomial needs independent trials with the same probability, and sessions next to each other in the file are more alike than random ones, so buyers cluster. In an interview, the strongest answer gives the formula, names the independence assumption, and says how you would test it, which is what the shuffle did.

How to answer probability questions

  • Use the complement for "at least one".
  • Turn rates into counts out of 1,000 or 10,000.
  • State assumptions, such as independence, equal probabilities and how the host behaves, before computing.
  • Check by simulation when unsure. Ten lines of Python and a fixed seed are enough.

The concepts are taught in probability for data science. How these ideas appear in experiments is covered in A/B testing for data scientists, and the full interview round in data science interview questions and answers.

What probability topics are asked in data science interviews?

Counting and combinations, conditional probability and Bayes' theorem, independence, expected value, common distributions such as binomial, geometric and Poisson, and classic puzzles such as the birthday problem and Monty Hall.

How do I solve Bayes' theorem questions quickly?

Imagine a concrete population, such as 10,000 people, split it by the base rate, apply the test's true and false positive rates to each part, and divide the true positives by all positives.

Can I use simulation in a probability interview?

Often yes, especially in take-home or live coding rounds. Give the exact reasoning first if you can, then show that a seeded simulation agrees.

What is the most common probability mistake in interviews?

Ignoring the base rate, and confusing P(A given B) with P(B given A). Both come from not asking which group the probability is about.

Probability for data work is part of the Data Science course.

Sources

GloryTecks Team

Training & Placement Faculty

The GloryTecks faculty team mentors learners across Data Science, AI and Data Engineering, with a focus on real-time projects and placement readiness in Hyderabad.

Want to master Interview Questions?

Join GloryTecks’ expert-led Data Science training in Hyderabad with real-time projects and 100% placement support.

Explore course