No student devices needed. Know more
14 questions
coffee = "kona"
tea = "mango"
smoothie = "raspberry"
coffee = "raspberry"
tea = "mango"
smoothie = "kona"
coffee = "kona"
tea = "kona"
smoothie = "kona"
coffee = ["kona", "mango", "raspberry"]
tea = ["kona", "mango", "raspberry"]
smoothie = ["kona", "mango", "raspberry"]
I only
II only
Both I and II
Neither I nor II
What does “packing” refer to in Python?
Creating a list
Initializing variables using values from a list
Storing multiple variables’ values by putting them in a collection, like a list or tuple
Cramming as many commands as possible onto a single line
red = "RED"
blue = "BLUE"
green = "GREEN"
red = "BLUE"
blue = "GREEN"
green = "RED"
red = ["BLUE", "GREEN", "RED"]
blue = ["BLUE", "GREEN", "RED"]
green = ["BLUE", "GREEN", "RED"]
red = "BLUE"
blue = "BLUE"
green = "BLUE"
board = [1, 2, 3] + [4, 5, 6] + [7, 8, 9]
board = [1, 2, 3]
board.append([4, 5, 6])
board.append([7, 8, 9])
board = [1, 2, 3, 4, 5, 6, 7, 8, 9]
board = []
board.append([1, 2, 3])
board.append([4, 5, 6])
board.append([7, 8, 9])
print(my_list[1])
print(my_list[1:2])
print(my_list[1][2])
print(my_list[2][3])
What does “unpacking” refer to in Python?
Creating a list
Initializing multiple variables at a time using a collection of values
Storing multiple variables’ values by putting them in a collection, like a list or tuple
Cramming as many commands as possible onto a single line
my_list = [i for i in range(6)]
my_list = [i*2 for i in range(6)]
my_list = [i for i*2 in range(6)]
This cannot be done using a list comprehension statement.
Tuple
List
Dictionary
2D list
tree
flower
weed
tree : oak
flower : daisy
weed : bindweed
oak
daisy
bindweed
tree oak
flower daisy
weed bindweed
print(my_list[1:3])
print(my_list[1:2])
print(my_list[2:3])
print(my_list[2:4])
A dictionary maps:
strings to strings
strings to numbers
indices to elements
keys to values
[7, 8]
[9, 10, 11]
[6, 7, 8]
[10, 11]
Explore all questions with a free account