Lists – Creation, online
Six activities your students do on their own devices. See who's finished, and their scores.
Learning
Understanding
Testing
Lists – Creation in one minute
What students need to know
A list is an ordered collection of items written inside square brackets, like colors = ['red', 'blue', 'green']. An empty list is created with just []. Each item is called an element, and len(list) returns how many elements it contains. Lists can hold any type of value — numbers, strings, even other lists — and the order items are added in is the order they stay in.
Mistakes students make
- Using parentheses instead of square brackets —
colors = ('red', 'blue', 'green')— creates a tuple, not a list, which behaves differently (it can't be changed after creation). - Square brackets are what make it a list.
PREVIOUS · MODULE 32String Formatting (.format())
YOU ARE HERE · MODULE 33Lists – Creation
NEXT · MODULE 34Lists – Indexing
What students will learn in this module
Every question in Module 33
Quick questions
- How do you create a list?ASquare brackets []BParentheses ()
- What does [] create?AAn empty stringBAn empty list
- Can a list hold different types?AYes strings, numbers, booleans, etc.BNo only one type
- What does len([1, 2, 3]) return?A2B3
- Are list items ordered?AYes they keep their orderBNo random order
Key terms
Students type the meaning of:
List[]Elementlen(list)
Match the pairs
nums = (1, 2, 3) nums.append(4)Match it to what it does
items = [1, 2, 3 print(items)Match it to what it does
colors = ['red', 'blue', 'green']Match it to what it doesmixed = [1, 'hi', True, 3.5]Match it to what it doesnums = [1, 2, 3] print(len(nums))Match it to what it does
items = [] print(items)Match it to what it does
Fill in the blanks
colors = _'red', 'blue', 'green'_
numbers = [10, 20, 30] print(___(numbers))
empty = __
pets = ['cat'_ 'dog'_ 'fish']
names = ['Alice', 'Bob'] _____(names)
Spot the error
Question 1
A# Create a list of colorsBcolors = ('red', 'blue', 'green')Cprint('First:', colors[0])Dprint('Count:', len(colors))
Question 2
A# Create a list of colorsBcolors = {'red', 'blue', 'green'}Cprint('First:', colors[0])Dprint('Count:', len(colors))
Question 3
A# Create a list of colorsBcolors = ['red' 'blue' 'green']Cprint('First:', colors[0])Dprint('Count:', len(colors))
Question 4
A# Create a list of numbersBnumbers = [1, 2, 3,]Cprint('First:', numbers[0])Dprint('Count:', len(numbers))
Question 5
Acolors = [red, blue, green]Bprint('First:', colors[0])Cprint('Count:', len(colors))Dprint('Done')
