| OCR |
GCSE (9-1) Computer Science
Mark Scheme
J277/02: Random Number Generation
|
| Question | Answer | Marks | Guidance |
|---|---|---|---|
| 1 |
1. random 2. 1 3. 6
|
3 |
Python requires
import random. Range must be 1 and 6. |
| 2 |
Any two from:
|
2 |
"Games" is the most common correct answer.
|
| 3a | 1 | 1 | |
| 3b | 5 | 1 |
Critical: OCR ERL and Python
randint are inclusive. "4" is incorrect. |
| 4a | A new random number is generated for each if/elif check (1). It is possible for every check to be False if different numbers are rolled sequentially (1). | 2 |
The Re-Roll Trap: Must explain that the number changes/regenerates.
|
| 4b |
num = random.randint(1, 3)
|
3 |
BP1: Assign to variable once at start. BP2: Use variable in checks.
|
| 5 |
num = random.randint(0, 1)
|
4 |
BP1: Generate random. BP2: Selection. BP3: Heads output. BP4: Tails output.
|
| 6 |
import random
|
6 |
BP2: Calculate length (
len). BP4: Correct handling of "Out of Bounds" (-1). |