Homeschool Guide: These lesson plans are a guide for parents. Content may contain errors — always cross-reference with official exam board specifications.

random number generation

FoundationHigherAll Boards

4 detailed 50-minute lessons with teaching scripts, worked examples, parent guides, and assessment criteria.

Fastmail

Lesson Overview

Total Lessons: 4
Tier: Foundation and Higher
Duration: 50 minutes per lesson (200 minutes total)
Exam Boards: AQA, Edexcel, OCR, Eduqas, CCEA

Learning Objectives

Prerequisites

Materials & Equipment

Lesson 1: Introduction: random number generation

Duration: 50 minutes

Starter Activity (5 minutes)

Quick Recall

Write down everything you already know about random number generation. Then check against the key terms: Random number generation, RANDOM(), Random numbers are essential in games. Use a mini-whiteboard or paper.

Main Content (35 minutes)

Parent/Teacher Guide:
Before lesson: Read the script below. Pre-teach key vocab: Random number generation, RANDOM(), Random numbers are essential in games.
If stuck: Re-read the revision notes (link above), then break the content into smaller steps.
Extension: See the Stretch & Challenge ideas in Lesson 4.
Teaching Script (35 mins):
Mins 0-5 - Hook: "Today: random number generation. By the end you will be able to answer exam questions on it unaided. It connects to the rest of Computer Science because the ideas here recur across the spec."
Mins 5-20 - Direct Instruction: Work through the core ideas below one at a time; after each, ask your student to explain it back in their own words.
Mins 20-30 - Guided Practice: Model the worked example together, then let your student attempt the first practice question with guidance.
Mins 30-35 - Independent Practice: 2-3 practice questions from Lesson 3 below, with immediate feedback.
First Look

Start with the revision notes summary, then attempt: Write pseudo-code to simulate rolling two dice and output the total.

Plenary (5 minutes)

Check Out

Your student states one thing they learned and one question they still have about random number generation.

Lesson 2: Core Concepts: random number generation

Duration: 50 minutes

Starter Activity (5 minutes)

Review Previous Lesson

Quick recap: write 3 key points from Lesson 1 on random number generation. Check them against the notes below.

Main Content (35 minutes)

Random number generation: produces numbers that appear unpredictable. In computing, most random numbers are actually pseudorandom - they are generated by a deterministic algorithm but appear random for practical purposes.
RANDOM(): generates a random number. In most pseudo-code specifications, it returns a random real number between 0 and 1 (not including 1). Some specifications use RANDOM(max) to return a random integer between 0 and max-1.
To generate a random integer in a range from min to max (inclusive),: you need to scale and shift the random number. The formula depends on which RANDOM function your specification uses.
Random numbers are essential in games: to create unpredictable and varied experiences. Without randomness, games would always play out exactly the same way.
Simulations: use random numbers to model real-world events that have an element of chance. This allows us to study complex systems without having to observe them in reality.
Random test data generation: can quickly produce large volumes of test data. This is useful for stress testing and finding edge cases that a programmer might not think of.
TermMeaningExample
Debugging / TestingFixed seed (e.g. 42)Same "random" numbers each run for reproducible results
Games / Real useSystem clock (auto-seed)Different numbers each run for true unpredictability
Security / CryptographyTrue random source (hardware)Pseudorandom is predictable and NOT secure enough

Practice (10 minutes)

Q: Write pseudo-code to simulate rolling two dice and output the total.

Answer: die1 ← RANDOM(6) + 1 die2 ← RANDOM(6) + 1 total ← die1 + die2 OUTPUT "You rolled ", die1, " and ", die2, " = ", total

Plenary (5 minutes)

Explain Back

Your student teaches the key points back to you without looking. Fill any gaps immediately.

Lesson 3: Application: random number generation

Duration: 50 minutes

Starter Activity (5 minutes)

Quick Recall

Recall the key terms: Random number generation, RANDOM(), Random numbers are essential in games. Define each in one sentence.

Main Content (35 minutes)

Parent/Teacher Guide: Let your student attempt each question alone first, then compare with the model answer. Award method marks for correct working even if the final answer is wrong.

Q1: Write pseudo-code to simulate rolling two dice and output the total.

Answer: die1 ← RANDOM(6) + 1 die2 ← RANDOM(6) + 1 total ← die1 + die2 OUTPUT "You rolled ", die1, " and ", die2, " = ", total

Q2: Write pseudo-code to generate a random number between 50 and 100 (inclusive).

Answer: number ← RANDOM(51) + 50 // RANDOM(51) gives 0-50, +50 gives 50-100

Q3: Explain what a seed is and why it is useful for debugging.

Answer: A seed is a starting value for the random number generator. The same seed always produces the same sequence of pseudorandom numbers. This is useful for debugging because you can reproduce the same "random" results each time you run the program, making it easier to find and fix errors.

Q4: Write pseudo-code that simulates a coin flip 10 times and counts the number of heads.

Answer: heads ← 0 FOR i ← 1 TO 10 flip ← RANDOM(2) // 0 or 1 IF flip = 0 THEN heads ← heads + 1 ENDIF NEXT i OUTPUT "Heads: ", heads

Q5: A game has a 1 in 8 chance of finding treasure. Write pseudo-code to simulate this.

Answer: chance ← RANDOM(8) // 0 to 7 IF chance = 0 THEN // 1 in 8 chance OUTPUT "You found treasure!" ELSE OUTPUT "No treasure here" ENDIF

Plenary (5 minutes)

Error Review

Review any questions answered incorrectly. Identify whether the error was knowledge, method, or reading the question.

Lesson 4: Exam Practice: random number generation

Duration: 50 minutes

Starter Activity (5 minutes)

Command Words

Review what these command words require: state (one point), describe (say what happens), explain (say why), compare (both sides), evaluate (judgement).

Main Content (35 minutes)

Extended Answer

Extended question: Full-Mark Response Write pseudo-code for a program that simulates rolling two dice and calculates the total. The program should roll 1000 times and count how many times the total is 7. Output the count and the percentage. [4 marks] <div class="

count ← 0 FOR i ← 1 TO 1000 die1 ← RANDOM_INT(1, 6) die2 ← RANDOM_INT(1, 6) total ← die1 + die2 IF total = 7 THEN count ← count + 1 ENDIF NEXT i percentage ← (count / 1000) * 100 OUTPUT 'Total of 7 appeared ' & count & ' times' OUTPUT 'Percentage: ' & percentage & '%'

Exam Tips: Know the formula: RANDOM(max - min + 1) + min for a range | Dice: RANDOM(6) + 1 for a standard 6-sided die | Percentage chances: RANDOM(100) gives 0-99, check if result < percentage | Remember that RANDOM() is pseudorandom - it is deterministic based on the seed | Seeding makes results reproducible - useful for testing | Random numbers are used in games, simulations, testing, and security
Common Errors: ✗ Thinking RANDOM() generates truly random numbers ✓ Computer-generated 'random' numbers are pseudo-random — they use a mathematical formula starting from a seed value. They are deterministic, not truly random. ✗ Forgetting to set the range when generating random numbers ✓ RANDOM() generates a decimal between 0 and 1 by default. To get integers in a range, use RANDOM_INT(min, max) or transform: INT(RANDOM() * (max - min + 1)) + min. ✗ Not understanding that the same seed produces the same sequence ✓ Pseudo-random number generators produce the same sequence for the same seed. This is useful for testing but means numbers are predictable if the seed is known. ✗ Confusing RANDOM_INT(1,6) with RA
Stretch & Challenge (Grade 8-9):
  • Synoptic links: explain how random number generation connects to another Computer Science topic you have studied
  • Real-world: research one real-world use or example of random number generation
  • Critical: "What are the limitations of the models used in random number generation?"

Plenary (5 minutes)

Assessment Criteria
  • Got it: Confident explanation + correct worked examples
  • Getting there: Main points OK, needs support with detail
  • Not yet: Confused on key concepts - re-run Lesson 2

Homework & Consolidation

Recommended Resources

🎓 Smart Lesson (Guided)