HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClasses

>_StemPy Lab

Learn. Solve. Code the solutions. Test yourself.

Live examsFree mock exams, timed and rankedEveryone starts together, and your score and rank come the moment it ends.See the exams →
Live examsInternational live exams are comingTell us which exam you want first. Timed practice papers are open now.See what is coming →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Computer Science
  • Space Science and Astronomy
  • Earth and Environmental Science
  • Classes
  • Groups

Practice

  • Problems
  • Quizzes
  • Mock Tests
  • Prepare for an Exam
  • Question Sets
  • Exams
  • Certificates
  • Python Labs
  • AI Practice Generator
  • Student-Created Tests

Community

  • Discussions
  • Resources
  • Notes
  • Glossary
  • Blog

Account

  • Log in
© 2026 senLearn. All rights reserved.HelpFor SchoolsAboutContactPrivacy PolicyTerms of UseRefund Policy
  1. Python Programming
  2. /Python for Science and Maths
  3. /Simulation and Randomness

Simulation and Randomness

Python Programming · High School (11–12) · 3 courses, 23 worked problems, 40 practice questions

Some events depend on chance, such as a coin toss, the decay of an atom or the path of a molecule in a gas. Python's random module gives random numbers, and NumPy can give millions at once. A simulation repeats a chance event many times and counts the results. With enough trials, the fraction of heads comes close to one half. This is the idea behind the Monte Carlo method. It can estimate π\piπ by scattering random points in a square, model radioactive decay or follow a random walk. Setting a seed makes a simulation repeat exactly.

With practice you will be able to

  • Simulate a coin or dice game many times and count outcomes
  • Estimate π\piπ with random points in a square
  • Model radioactive decay with random numbers

On the syllabus of

  • CBSE / State Class 12
  • AP

Lessons

  • Growth and Populations by ComputerWhy can no population keep doubling for ever? How do you read growth from scattered counts?High School (11–12)
  • Genetics by ComputerWhy do pea crosses give 3 tall to 1 short? Why do small samples miss that ratio?High School (11–12)
  • Simulation and RandomnessCan random dots find π? How far does a random walker wander?High School (11–12)

Practice questions

Choose an answer, then check it. Each one shows a full explanation.

A loop follows a culture of Amoeba through four divisions. What does it print? N = 70; for i in range(4):; N = 2 * N; print(N)

A culture of 160 cells doubles every 35 min. What does this print? print(160 * 2 ** (105 / 35))

A culture doubles every 353535 min. Which expression gives its growth rate rrr per minute, for N=N0ertN = N_0 e^{rt}N=N0​ert?

Worked problems

Each one has a hint, the key idea and a full worked solution.

  • In a culture kept by Meera's class, each Paramecium divides by binary fission about every 8 hours…Easy
  • A strain of bacteria grows as N = N₀ eʳᵗ with r = 1.8 per hour…Easy
  • A culture starts with 400 cells and doubles every 25 minutes…Medium
  • Aditi plots ln N against t in minutes for a culture with a doubling time of 40 min…Medium

Python labs

  • A population stepper
  • Fitting growth curves
  • Simulating many crosses
  • Roll the dice
  • Estimate a probability
  • Random walk

Related topics

  • Python for Science and Maths
  • NumPy Arrays
  • Graphs with matplotlib
  • Solving Equations
  • Calculus by Computer
  • Data Analysis with pandas
  • Chemistry by Computer
  • Biology by Computer
  • Trigonometry and Waves by Computer

Counts that grow exponentially are plotted with plt.yscale("log"). What shape do they make?

Counting times for a growth experiment, in minutes. What does this print? import numpy as np; t = np.arange(0, 61, 15); print(len(t), t[-1])

In logistic growth, how does the population grow while NNN is very small compared with KKK?

One logistic step for a pond of algae. What does it print? r, K, N, dt = 0.25, 1500, 375, 2; N = N + r * N * (1 - N / K) * dt; print(N)

Yeast in a brewing vat stops multiplying once it holds 150015001500 cells. How many cells does the vat hold when the count rises most quickly?

A fit to three counts. What does it print? import numpy as np; t = np.array([0, 10, 20]); N = np.array([90, 180, 360]); slope, c = np.polyfit(t, np.log(N), 1); print(round(np.log(2) / slope, 1))

What does curve_fit(model, t, N, p0=[0.25, 950]) return first?

All 40 practice questions on Simulation and Randomness →

A population of algae in a tank grows logistically from 20 cells, with r = 0.4 per hour and a…
Medium
  • Sanjay steps a logistic population with r = 0.8 per hour, K = 300 cells and N₀ = 5 cells, for 12…Medium
  • Counts of a yeast culture every hour are 50, 100, 195, 360, 560, 700 and 760 cells…Easy
  • A culture has 3000 cells at 10:00 and 48 000 cells at 12:00…Easy
  • Ritu fits a straight line to her counts with slope, intercept = np.polyfit(t, np.log(N), 1), with t…Medium
  • Duckweed spreads over a village pond. Nisha counts the fronds every 3 days: Fit a logistic curve…Hard
  • A program crosses Tt with Tt for 2000 plants…Easy
  • Dev simulates Tt with tt using random.choice(mum) + random.choice(mum), where mum = "Tt" and dad =…Medium
  • All 23 worked problems on Simulation and Randomness →