Random numbers with import random
Gives your program the random module. Then random.randint(1, 6) gives a random whole number from 1 to 6, and random.choice(my_list) picks a random item from a list.
Understanding Random numbers with import random in VCE Software Development U4O1
What it does: random.randint(1, 6) makes the number and the = stores it in the variable roll. random.choice() takes a list and returns one random item from it. Python uses the import keyword to load a module. The line import random gives your program access to the random module. randint needs two numbers: the lowest and the highest value it can give. random.randint(1, 6) can return 1, 2, 3, 4, 5 or 6. The smaller number goes first and the larger number goes second. randint(15, 5) causes an error. randint(a, b) picks a whole number between a and b, and both ends can be chosen, like rolling a dice.
Common mistakes: A single = assigns a value. To compare dice with 6 you need ==, so the line should be: if dice == 6:. The module name is spelled wrong. It must be random, so the line should be: import 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 115–124) and word search (Modules 115–171).
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
import randomFill in the Blanks
Spot the Error
Student with a class code? Join your class →