1
2
3
4
5
6
7
8
9
10
11
12
To practice on your own, or to check code you believe shouldn't have been scored as incorrect, go to Trinket.
Post a review on Amazon for the paperback or the Kindle edition.
Email me to give me a compliment, complaint, or correction. I'll respond.
0,1,2,3,4,5,6,7,8,9,10,11
0
0
0
0
The last key-value pair in the dictionary is this list. What is the name of the list? | "discounts": ["standard", "volume", "loyalty"], | "discounts" | ^ *•discounts• *$ |
What is the element in the list with an index number of 1? | "discounts": ["standard", "volume", "loyalty"], | "volume" | ^ *•volume• *$ |
Fill in the blank to specify the last element of the list, "loyalty"—and close the list. Remember to end the line with a comma. | "discounts": ["standard", "volume", _____________ | "loyalty"], | "`loyalty`"`]`, |
Extend this dictionary by coding the next key-value pair. It's a list named "a list". The elements are the integers 1, 2, 3. Remember to indent and to end the line with a comma. | dict = { "nation": "Uganda", | "a list": [1, 2, 3], | "a list": [1, 2, 3], |
Code a dictionary that contains just one item. The item is a list that contains just one element. The key is a string. The single element in the list is an integer. Make everything up. Remember to end the list definition with a comma. | x = { "count": [788], } |
^ *[a-zA-Z_][a-zA-Z0-9_]* = {\n •.+•: \[-?[0-9]+\],\n} *$ | |
Code a dictionary that contains just one item. The item is a list that contains two elements. The key is a string. The elements in the list are strings. Make everything up. Remember to end the list definition with a comma. | x = { "names": ["Don", "Dean"], } |
^ *[a-zA-Z_][a-zA-Z0-9_]* = {\n •.+•: \[•.+•, •.+•\],\n} *$ | |
Code a dictionary that contains two items. The first item is key-value pair. The key and the value are both integers. The second item is a list that contains two elements. The key is an integer. The elements in the list are also integers. Make everything up. Remember to end the list definition with a comma. | x = { 3: 4, 5: [6, 7], } |
^ *[a-zA-Z_][a-zA-Z0-9_]* = {\n -?[0-9]+: -?[0-9]+,\n -?[0-9]+: \[-?[0-9]+, -?[0-9]+\],\n} *$ | |
Code a dictionary that contains two items. Both items are lists. Each list contains two elements. All keys, values, and list items are strings. Make everything up. | x = { "flowers": ["rose", "daffodil"], "trees": ["palm", "fir"], } |
^ *[a-zA-Z_][a-zA-Z0-9_]* = {\n •.+•: \[•.+•, •.+•\],\n •.+•: \[•.+•, •.+•\],\n} *$ | |
Code a list that contains one dictionary. The dictionary contains one pair. The key is a string. the value is an integer. Make everything up. You'll need two commas: one after the pair, and one after the closing curly bracket. | tiny_list = [ { "universe": 1, }, ] |
^ *[a-zA-Z_][a-zA-Z0-9_]* = \[\n {\n •.+•: -?[0-9]+,\n },\n\] *$ | |
Code a dictionary that contains two lists. The keys are strings. Each list contains three integers. Make everything up. | dict = { "some numbers": [1, 2, 3], "other numbers": [4, 5, 6], } |
^ *[a-zA-Z_][a-zA-Z0-9_]* = {\n •.+•: \[-?[0-9]+, -?[0-9]+, -?[0-9]+\],\n •.+•: \[-?[0-9]+, -?[0-9]+, -?[0-9]+\],\n} *$ | |
|
124c57b0df | ||
|
7c8c89614e |