RANDOM: a random number between 0 and 1
A library routine with empty brackets that returns a random REAL number from 0 to 1 inclusive, a different value each time it is called. Store it, e.g. Num ← RANDOM()
Understanding RANDOM: a random number between 0 and 1 in IGCSE Computer Science Paper 2
What it does: Nothing goes inside the brackets of RANDOM() because it needs no input value. RANDOM() returns a value such as 0.37, which is a REAL, so the receiving variable must be REAL, not INTEGER. RANDOM takes no arguments, so the brackets are left empty. The result is a REAL number, so it usually has a decimal part. Each call produces a new random value, so the two results will usually differ. The variable goes on the left of the assignment arrow and the RANDOM() call goes on the right. The empty brackets are needed to call the routine. Without them it is not a valid call.
Common mistakes: RANDOM() returns a REAL number between 0 and 1, so the variable that stores it must be declared as REAL, not INTEGER. RANDOM() takes no arguments, so the brackets must be empty. It should be Chance ← RANDOM().
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 429–438) and word search (Modules 419–438).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
RANDOM()Fill in the Blanks
Spot the Error
Student with a class code? Join your class →