RNG Power 0 / 27
RNG Rank Coin Tosser

Topic 2.2.11: Random Number Generation

Using randint, Simulations & Logic.

1 [3 Marks]
import ......................... roll = random.randint(........., .........) print(roll)
Simulate a 6-sided die.
✅ Mark Scheme
  • random
  • 1
  • 6
Score:
2 [2 Marks]
Two applications of Random Numbers?
✅ Mark Scheme

Computer Games (Simulations), Cryptography/Security, Financial Modelling.

Score:
3 [2 Marks]
myNum = random(1, 5)
(a) Lowest possible value?
(b) Highest possible value?
✅ Mark Scheme

(a) 1

(b) 5 (Inclusive in OCR/Python generally assumed unless specified).

Score:
4 [5 Marks]
if random.randint(1, 3) == 1: print("Yes") elif random.randint(1, 3) == 2: print("No") elif random.randint(1, 3) == 3: print("Maybe")
(a) Logic Error? (Why sometimes no output?)
(b) Rewrite code correctly.
✅ Mark Scheme

(a) It generates a NEW number for each check. Possible to fail all checks (e.g. roll 2, then roll 3, then roll 1).

num = random.randint(1, 3)
if num == 1:
    print("Yes")
elif num == 2:
    print("No")
else:
    print("Maybe")
Score:
5 [4 Marks]
Write a Coin Toss program (Heads/Tails).
✅ Mark Scheme
num = random.randint(0, 1)
if num == 0:
    print("Heads")
else:
    print("Tails")
Score:
6 [6 Marks]
students = ["Ali", "Bea", "Caz", "Dan", "Eve"]
Pick a random student name.
Constraint: Must work if more names added (don't hardcode 4).
✅ Mark Scheme
import random
max_index = len(students) - 1
r = random.randint(0, max_index)
print(students[r])
Score: