Placement Aptitude (Quant, Logical, Verbal) Module 9 – Counting, probability and statistics
Probability: coins, dice, cards and balls
Classical probability from equally likely outcomes, the complement, the addition rule and independence, worked on coins, dice, cards and balls.
What you will learn
- Calculate classical probabilities from equally likely outcomes
- Use complements, independent events and the addition rule
- Solve dice, card, coin and urn problems without counting errors
Before you start
What you’ll learn · Before you start
What you will learn
- Calculate classical probabilities from equally likely outcomes
- Use complements, independent events and the addition rule
- Solve dice, card, coin and urn problems without counting errors
Before you start
On this page
Probability measures how likely an event is, on a scale from 0 (impossible) to 1 (certain). When every outcome of an experiment is equally likely, P(E) = favourable outcomes ÷ all outcomes: a die shows an even number with probability 3/6 = 1/2, and two dice make a total of 7 in 6 of their 36 ordered outcomes, so with probability 1/6. Three rules do most of the work. P(not E) = 1 − P(E). P(A or B) = P(A) + P(B) − P(A and B), which loses its last term when A and B cannot happen together. And for independent events, P(A and B) = P(A) × P(B). Aptitude items use coins, dice, cards and balls in a bag, and most wrong answers come from a sample space listed wrongly, not from the arithmetic.
Sample spaces: list them, do not guess
NCERT’s Class 10 textbook builds probability on equally likely outcomes, so the first job in every item is to list outcomes that really are equally likely. n coins give 2ⁿ outcomes, in which HHT and HTH count separately. Two dice give 36 ordered pairs, shown in the grid. A standard deck has 52 cards in 4 suits of 13; 12 of them are face cards (jack, queen and king) and 26 are red. Balls drawn together from a bag are counted with combinations: two balls from 8 give C(8, 2) = 28 equally likely pairs.
The 36 ordered rolls of two dice and their totals
Text description of the diagram
The grid has six rows for the first die (1 to 6) and six columns for the second die (1 to 6). Each of the 36 cells holds the total of its row and column, from 2 in the top left corner to 12 in the bottom right.
Equal totals run along diagonals from the bottom left to the top right. The total 7 fills the longest of these diagonals, six cells, which are outlined and shaded: 1 and 6, 2 and 5, 3 and 4, 4 and 3, 5 and 2, and 6 and 1. So a total of 7 has probability 6/36 = 1/6, the highest of any total.
The totals 2 and 12 each have only one cell (1/36), the totals 3 and 11 two cells, and so on, which is why the eleven totals are not equally likely.
The rules, and when each one applies
| Rule | Use it when | Example |
|---|---|---|
| P(not E) = 1 − P(E) | The item says “at least one”, or E is long to count | At least one head in 3 tosses: 1 − 1/8 = 7/8 |
| P(A or B) = P(A) + P(B) | A and B cannot happen together | A die shows 1 or 6: 2/6 = 1/3 |
| P(A or B) = P(A) + P(B) − P(A and B) | A and B can happen together | A red card or a king: 26/52 + 4/52 − 2/52 = 7/13 |
| P(A and B) = P(A) × P(B) | One result does not change the other | Two sixes in two rolls: 1/36 |
| Multiply along the draws | Each draw leaves one item fewer | Two aces: 4/52 × 3/51 = 1/221 |
With replacement or without
With replacement, every draw sees the same bag, so the draws are independent. Without replacement, the second draw sees one item fewer, and its chances depend on the first. Drawing two balls at once is the same as drawing them one after the other without replacement. A simulation builds intuition, but a test marks exact fractions, so every answer below is exact and the simulation only confirms it.
Five solved examples
- Coins. With three coins, at least two heads covers HHH, HHT, HTH and THH, 4 of the 8 outcomes: 1/2.
- Dice. With two dice, a total of at least 10, a doublet and a total of 7 each fill 6 cells of the grid, so each has probability 1/6, although they are three different events.
- Cards. One card from 52: a face card, 12/52 = 3/13. A king or a heart, 4/52 + 13/52 − 1/52 = 16/52 = 4/13, since the king of hearts is in both groups.
- Balls. A bag holds 5 red and 3 blue balls, and two are drawn without replacement. Both red: C(5, 2)/C(8, 2) = 10/28 = 5/14, which equals 5/8 × 4/7. With replacement it would be (5/8)² = 25/64.
- At least one six in four rolls. The complement, no six at all, has probability (5/6)⁴ = 625/1296, so the answer is 671/1296, about 0.518.
# The five solved examples of the lesson: each probability is counted exactly over the full sample space, as a
# fraction, and then estimated by a seeded simulation of 100,000 trials. The seed makes every run print the same.
import random
from fractions import Fraction
from itertools import combinations, product
def exact(space, event):
"""The probability of an event over equally likely outcomes, as an exact fraction."""
space = list(space)
return Fraction(sum(1 for outcome in space if event(outcome)), len(space))
def simulate(trial, n=100_000):
"""The share of n seeded trials in which the event happened."""
return sum(1 for _ in range(n) if trial()) / n
random.seed(2026)
die = lambda: int(random.random() * 6) + 1 # random.random() gives the same sequence on every Python version
coin = lambda: 'H' if random.random() < 0.5 else 'T'
def two_without_replacement(items):
"""Two different items drawn at random, built from random.random() alone."""
first = int(random.random() * len(items))
rest = items[:first] + items[first + 1:]
return [items[first], rest[int(random.random() * len(rest))]]
# 1. Three coins, at least two heads.
p = exact(product('HT', repeat=3), lambda s: s.count('H') >= 2)
print(f"1. At least two heads in 3 coins: {p} = {float(p):.3f}; simulated {simulate(lambda: [coin() for _ in range(3)].count('H') >= 2):.3f}")
# 2. Two dice: a sum of at least 10, a doublet, and a sum of 7.
two = list(product(range(1, 7), repeat=2))
for name, event in (("sum at least 10", lambda s: sum(s) >= 10), ("a doublet", lambda s: s[0] == s[1]), ("sum 7", lambda s: sum(s) == 7)):
p = exact(two, event)
print(f"2. Two dice, {name}: {p} = {float(p):.3f}; simulated {simulate(lambda: event((die(), die()))):.3f}")
# 3. One card from 52: a face card, and a king or a heart.
deck = [(rank, suit) for rank in 'A23456789TJQK' for suit in '♠♥♦♣']
face = exact(deck, lambda c: c[0] in 'JQK')
king_or_heart = exact(deck, lambda c: c[0] == 'K' or c[1] == '♥')
print(f"3. A face card: {face}; a king or a heart: {king_or_heart} = 4/52 + 13/52 − 1/52")
# 4. A bag of 5 red and 3 blue balls; two drawn without replacement, then with replacement.
bag = 'RRRRRBBB'
without = exact(combinations(range(8), 2), lambda pair: all(bag[i] == 'R' for i in pair))
with_back = exact(product(range(8), repeat=2), lambda pair: all(bag[i] == 'R' for i in pair))
print(f"4. Both red without replacement: {without} = 5/8 × 4/7; with replacement: {with_back} = (5/8)²")
print(f" simulated without replacement: {simulate(lambda: two_without_replacement(bag) == ['R', 'R']):.3f}")
# 5. At least one six in four rolls of a die.
p = exact(product(range(1, 7), repeat=4), lambda r: 6 in r)
print(f"5. At least one six in 4 rolls: {p} = 1 − (5/6)⁴ = {float(p):.4f}; simulated {simulate(lambda: 6 in [die() for _ in range(4)]):.4f}") Output
1. At least two heads in 3 coins: 1/2 = 0.500; simulated 0.502 2. Two dice, sum at least 10: 1/6 = 0.167; simulated 0.164 2. Two dice, a doublet: 1/6 = 0.167; simulated 0.165 2. Two dice, sum 7: 1/6 = 0.167; simulated 0.166 3. A face card: 3/13; a king or a heart: 4/13 = 4/52 + 13/52 − 1/52 4. Both red without replacement: 5/14 = 5/8 × 4/7; with replacement: 25/64 = (5/8)² simulated without replacement: 0.358 5. At least one six in 4 rolls: 671/1296 = 1 − (5/6)⁴ = 0.5177; simulated 0.5179
Recorded with Python 3.14.8 on macOS 26 arm64. To run it yourself: mise exec python@3.14.8 -- python3 check_five.py
Runs on this device, in your browser. The first run downloads Python (about 13.5 MB), which is kept for the next runs.
Your run, in this browser
The program counts every answer exactly over the full sample space, then simulates each experiment 100,000 times with a fixed seed. Every simulated share landed within 0.003 of the exact value, the size of wobble to expect from that many trials; the exact fraction is the answer, and the simulation is the check.
Dice Roller (d4 to d100) Roll two dice as often as you like, and watch the totals pile up around 7 as the grid predicts.Exercise: exact chances for dice totals
The exercise works out the exact chance of any total of up to eight dice and of an event happening at least once, and the ten questions after it are untimed.
Exercise · Medium · Python
Exact chances for dice totals and repeated tries
Write two functions in dice.py, the file the tests import. Both return exact fractions.Fraction values, never floats.
total_chance(dice, total)returns the probability thatdicefair six-sided dice add up to exactlytotal.total_chance(2, 7)isFraction(1, 6), and a total the dice cannot make has probability 0.at_least_once(p, tries)returns the probability that an event of probabilityp(aFraction) happens at least once intriesindependent tries:at_least_once(Fraction(1, 6), 4)isFraction(671, 1296), the lesson's four rolls.
The tests include eight dice, which have 16,79,616 outcomes, so build the totals up one die at a time instead of listing every roll.
Starter code · dice.py
from fractions import Fraction
def total_chance(dice, total):
"""The probability that this many fair dice add up to exactly the total, as a Fraction."""
# Replace this line with your code.
return Fraction(0)
def at_least_once(p, tries):
"""The probability that an event of probability p happens at least once in independent tries."""
# Replace this line with your code.
return Fraction(0) The sample tests · test_dice.py
from fractions import Fraction
from dice import at_least_once, total_chance
def test_two_dice():
"""A total of 7 is the most likely total of two dice"""
assert total_chance(2, 7) == Fraction(1, 6)
assert total_chance(2, 2) == Fraction(1, 36)
def test_three_and_four_dice():
"""27 of the 216 rolls of three dice make 10, and 146 of 1,296 rolls of four make 14"""
assert total_chance(3, 10) == Fraction(1, 8)
assert total_chance(4, 14) == Fraction(73, 648)
def test_impossible_totals():
"""One die cannot make 7, and two dice cannot make 1"""
assert total_chance(1, 7) == 0
assert total_chance(2, 1) == 0
def test_eight_dice_without_listing():
"""135,954 of the 16,79,616 rolls of eight dice add up to 28"""
assert total_chance(8, 28) == Fraction(7553, 93312)
def test_at_least_once():
"""Four rolls for a six, and no tries at all"""
assert at_least_once(Fraction(1, 6), 4) == Fraction(671, 1296)
assert at_least_once(Fraction(1, 2), 0) == 0
def test_answers_are_exact():
"""Fractions, not floats"""
assert isinstance(total_chance(2, 7), Fraction)
assert isinstance(at_least_once(Fraction(1, 6), 4), Fraction) A hint
Keep a table of how many ways each total can happen. One die makes each of 1 to 6 in one way. Adding a die, the ways to make a total t are the ways the earlier dice made t − 1, t − 2, …, t − 6, added up. After the last die, divide the ways for the total you want by 6 to the power of the number of dice. For at_least_once, use the complement: 1 − (1 − p) to the power of tries.
Results of the sample tests
| Test | Result | Details |
|---|
What your code printed
The sample tests run on this device, in your browser (Pyodide): nothing is sent to mysmartcopilot.com. The first run downloads Python (about 13.5 MB), which is kept for the next runs. A check in your browser is feedback for you, not proof that the code is right for every input.
Ten untimed questions on probability
10 questions about this lesson. Every answer and why it is right is on the page, behind “Show the answer”. Your score stays in this browser.
Twelve coin, dice, card and ball items with full working Pro: opens with a Pro, Premium or Ultimate pass
Most probability items are one of a dozen shapes, and each shape has a fastest route: symmetry, the complement or counting with combinations. The twelve original items below each take that route, and a program then counts every answer again over its full sample space.
In this part:
- Coins and dice, by symmetry and the complement
- Cards drawn one after another
- Balls in a bag, counted with combinations
- Independent events, with numbers
1 runnable example (Python) · about 2 minutes
Opening this part with your pass…
This part opens with any MySmartCoPilot pass.
- Pro pass · 1 week₹79$2.99
- 30 days₹179$5.99
- 1 year₹1,699$45
One payment; a pass never renews. The price shown is the total you pay: no fees or charges are added at checkout.
Passes can’t be bought right now, so this part can’t be opened at the moment. The free part above stands on its own. If you have a pass, enter your licence key.
It also opens every other in-depth part in Learn and every Pro tool. Sales are final, except where the law gives you a right to withdraw, for example in the EU and the UK (refund policy).
Five counting errors reproduced, and the check that catches each Pro: opens with a Pro, Premium or Ultimate pass
Wrong probability answers usually come from five errors that produce believable numbers. This part reproduces each one, sets its answer against the exact count over the full sample space and a seeded simulation of 200,000 trials, and gives the quick check that would have caught it.
In this part:
- E1: the eleven totals taken as equally likely
- E2: “no head, one head or two heads”, so one head is 1/3
- E3: adding events that overlap
- E4: draws without replacement multiplied as if replaced
- E5: “at least one” as n × p
1 runnable example (Python) · about 2 minutes
Opening this part with your pass…Pro part. It opens with the same pass as the part above.
A 12-minute set of ten items, with answers and a rubric Pro: opens with a Pro, Premium or Ultimate pass
Coins, dice, cards and balls all appear in these ten items, which suit a pace of about 70 seconds each. Time yourself for 12 minutes, then mark the set from the working and find your band in the rubric.
In this part:
- Ten mixed items, 12 minutes
- The answers, each with its shortest working
- What your score says, as a rubric
1 runnable example (Python) · about 2 minutes
Opening this part with your pass…Pro part. It opens with the same pass as the part above.
Interview questions
-
Fresher · Warm-up
Why is 7 the most likely total when two dice are rolled?
The two dice give 36 equally likely ordered outcomes, and the total 7 can be made in more of them than any other total: (1, 6), (2, 5), (3, 4), (4, 3), (5, 2) and (6, 1), six in all, so its probability is 6/36 = 1/6. Every die face can be paired with exactly one face of the other die to make 7, which is why 7 reaches six ways. Totals further from 7 have fewer ways: 6 and 8 have five each, and 2 and 12 have only one each, so they have probability 1/36. Treating the eleven totals from 2 to 12 as equally likely, which gives 1/11, is the classic mistake.
-
Fresher to mid
A quiz app shows one of 5 questions at random each day, repeats allowed. A friend says a given question is certain to appear within 7 days, since 7 × 1/5 is more than 1. Explain the error, give the exact chance, and find the days needed for a 90 % chance.
-
Fresher
A bag holds 5 red and 7 blue balls, and two are drawn without replacement. A student says P(one red and one blue) = 5/12 × 7/11. Why is that half the right answer, what is the right one, and how do you check it with combinations?
-
Fresher to mid
Two events each have probability 0.4. Can they be both independent and mutually exclusive? Explain the difference, and what P(A or B) is in each case.
Key takeaways
- P(E) = favourable ÷ all outcomes, but only when the outcomes are equally likely.
- List ordered outcomes for dice and coins: 36 for two dice, 2ⁿ for n coins.
- P(not E) = 1 − P(E) handles “at least one”.
- Add for events that cannot happen together; otherwise subtract the overlap.
- Multiply for independent events; without replacement, update each draw.
References
- Mathematics, Class 10, Chapter 14: Probability (National Council of Educational Research and Training (NCERT))
- Ganita Manjari, Grade 9, Part I, Chapter 7: The Mathematics of Maybe: Introduction to Probability (National Council of Educational Research and Training (NCERT))
- Mathematics, Class 11, Chapter 14: Probability (National Council of Educational Research and Training (NCERT))
- fractions: Rational numbers (Python Software Foundation)
- random: notes on reproducibility (Python Software Foundation)
Related tools
Report a problem with this lesson
Kept only in this browser. Your Learn progress