For the string s = "mango", this is the value returned by the expression s[4].
What is "o"?
This character separates the elements of a tuple.
What is a comma?
The type of brackets used to define and instantiate a list in Python.
What are square brackets []?
What you use to access a value in a dictionary.
What is a key?
This property is shared by both lists and dictionaries, allowing their contents to be changed after creation.
What is mutability?
The Python string method you would use on the string " hello " to remove all leading and trailing blank spaces.
What is .strip()?
This is the specific property of a tuple that prevents you from changing an element, such as
t = ("Apples", 15, "Sunrise")
t[2] = "sunset"
What is immutability?
The method you would use to add the single element 21 to the end of the list lFavourites.
What is .append(21)?
The value you would get if you attempted to access a non-existent key using the .get() method?
What is None?
The Python keyword used to check if a specific key exists within a collection.
What is in?
What is the index of the character 's' in the string "strawberry"?
What is 0?
The term for when multiple variables are assigned at once from a tuple, like in
sTypeOfDessert, sFlavour = tDessert.
What is unpacking (or tuple assignment)?
This is the value of
list_1 = [1, 2]
list_2 = [3, 4]
new_list = list_1 + list_2
What is [1, 2, 3, 4]?
The method used to add or change multiple key-value pairs in a dictionary at once.
What is .update()?
This specific type of error occurs if you try to use my_list[5] when my_list only has 4 elements.
What is an IndexError?
This is the result of the expression 'eggs, bananas, bread'.split(', ')[1]
What is "bananas"?
This is the resulting value printed from
tDessert = ("Cake", "Vanilla")
print(tDessert[0])
What is "Cake"?
The output of this expression
my_list = ['hello', 2, ['one', 2, 'three'], ('cake', 'chocolate'), True]
print(len(my_list))
What is 5?
The expression you would use to remove the key-value pair for "Manitoba" from the dCapitalCities dictionary.
dCapitalCities = {"Manitoba": "Winnipeg", "Alberta": "Edmonton", "Ontario": "Ottawa", "BC": "Victoria"}
What is del dCapitalCities["Manitoba"]?
The method you would call on a list of numbers to find the element with the largest value.
What is .max()?
This is the output of s = "strawberry"; print(s[-3:]).
What is "rry"?
This is the value printed by the expression
tExRaptors = ( ("Lowry", "76ers", 3.9), ("Siakam", "Knicks", 20.2) )
print(tExRaptors[1][0])
What is "Siakam"?
This is the output of
my_list = ['a', 'b', ['a', 'c'], 'a']
print(my_list.count('a'))
What is 2?
The expression to retrieve the population of British Columbia from this dictionary
CanadianProvinces = {"AB": {"name": "Alberta", "capital": "Edmonton", "population": 4413146},
"BC": {"name": "British Columbia", "capital": "Victoria", "population": 5231001},
"MB": {"name": "Manitoba", "capital": "Winnipeg", "population": 1379263}}
What is CanadianProvinces["BC"]["population"]?
In the list of dictionaries dCars, this expression is used to access the Model of the first car.
dCars = [{"Make": "Toyota", "Model": "RAV4", "Year":2010, "Colour": "Blue"},
{"Make": "Nissan", "Model": "Micra", "Year":2019, "Colour":"Teal"},
{"Make": "Subaru", "Model": "Impreza", "Year": 2015, "Colour":"Grey"}
]
What is dCars[0]["Model"]?