Creating an array of a set size
Creates a one-dimensional array (list) of 10 elements that all start with the value 0. Change the number to set the size, or use '' for strings.
Understanding Creating an array of a set size in VCE Software Development U3O1
What it does: The constant SIZE holds the array length, so changing it once updates the array size everywhere it is used. After the array is created, an element is filled by using its index in square brackets. Index 2 is the third element because indexes start at 0. [0] is the starting value and * 10 is the size. Swapping them gives a list of zero elements. '' is an empty string, so each of the 5 elements starts as an empty string, not the number 0. Storing the size in a constant such as SIZE means you only change it in one place. size() is not a Python function for this.
Common mistakes: x is not a Python operator, so this is a syntax error. Use * to repeat the element: scores = [0] * 10. Repeating an empty list still gives an empty list with 0 elements. Put an empty string inside the brackets: names = [''] * SIZE.
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 72–96) and word search (Modules 72–113).
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
scores = [0] * 10Fill in the Blanks
Spot the Error
Student with a class code? Join your class →