Random numbers rarely appear alone; they are combined with the other constructs.
A guessing game — random plus indefinite iteration
target ← RANDOM_INT(1, 100)
attempts ← 0
REPEAT
OUTPUT 'Guess a number between 1 and 100'
guess ← STRING_TO_INT(USERINPUT)
attempts ← attempts + 1
IF guess < target THEN
OUTPUT 'Too low'
ELSE IF guess > target THEN
OUTPUT 'Too high'
ENDIF
UNTIL guess = target
OUTPUT 'Correct! You took ', attempts, ' attempts'
Note the target is generated ONCE, before the loop. Putting RANDOM_INT inside the loop would pick a new target on every guess and the game could never be won — a classic exam fault.
Rolling two dice — two separate calls
dice1 ← RANDOM_INT(1, 6)
dice2 ← RANDOM_INT(1, 6)
total ← dice1 + dice2
OUTPUT 'You rolled ', dice1, ' and ', dice2, ' — total ', total
Here two calls are correct, because you genuinely want two independent dice. Compare that with the earlier bug, where one value was needed twice. The question is always: do I want one value or two?
A random question from a bank
questions ← ['What is 2+2?', 'Capital of France?', 'Largest planet?']
FOR i ← 1 TO 3
index ← RANDOM_INT(0, LEN(questions) - 1)
OUTPUT questions[index]
answer ← USERINPUT
ENDFOR
⚠️ This can repeat questions, because nothing stops the same index being chosen twice. Recognising that limitation — and suggesting that chosen questions be removed from the list or marked as used — is a strong AO3 observation.
Simulating probability
# A 30% chance of an event happening
IF RANDOM_INT(1, 100) ≤ 30 THEN
OUTPUT 'Event happened'
ENDIF
RANDOM_INT(1, 100) gives 100 equally likely values, and exactly 30 of them (1 to 30) satisfy ≤ 30 — giving a 30% probability. Note the ≤: using < would give only 29 values and a 29% chance.
AQA tip. Generate a random value once, in the right place, and store it. Most faults in this subtopic are about where the call is placed rather than the call itself.