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
Eliminate a list element using the element's value, which is "gold". Make up the name of the list. | metals.remove("gold") | ^ *[a-zA-Z_][a-zA-Z0-9_]*\.remove\(•gold•\) *$ | |
Eliminate a list element using the element's index number. Make up the name of the list and the index number. | del nations[0] | ^ *del [a-zA-Z_][a-zA-Z0-9_]*\[[-]?(?:[.]\d+|\d+(?:[.]\d*)?)\] *$ | |
Complete the code to eliminate the item whose key is "part 355". | del maritime_equipment_________ | ["part 355"] | [`"`part 355`"`] |
Eliminate the element whose key is "fifth place" from the dictionary winners. | del winners["fifth place"] | del winners["fifth place"] | |
Delete a dictionary item whose key is an integer. Make everything up. | del levels[9] | ^ *del [a-zA-Z_][a-zA-Z0-9_]*\[[-]?(?:[.]\d+|\d+(?:[.]\d*)?)\] *$ | |
Delete a dictionary item whose key is a string. Make everything up. | del prices["buggy whip"] | ^ *del [a-zA-Z_][a-zA-Z0-9_]*\[•.+•\] *$ | |
Delete the second item in this dictionary: | numbers = { "first": 1, "second": 2, "third": 3, "fourth": 4, } | del numbers["second"] | del numbers\[•second•\] |
Change the value of the third item to 3.0 | numbers = { "first": 1, "second": 2, "third": 3, "fourth": 4, } | numbers["third"] = 3.0 | ^ *numbers\[•third•\] = 3\.0 *$ |
Code a three-item dictionary in five lines of code. Then delete the first item. The keys are numbers. The values are strings. Make everything up. | syllables = { 1: "fee", 2: "fi", 3: "fo", } del syllables[1] | ^ *([a-zA-Z_][a-zA-Z0-9_]*) = {\n ([-]?(?:[.]\d+|\d+(?:[.]\d*)?)): •.+•,\n [-]?(?:[.]\d+|\d+(?:[.]\d*)?): •.+•,\n [-]?(?:[.]\d+|\d+(?:[.]\d*)?): •.+•,\n}\ndel \1\[\2\] *$ | |
Code a three-item dictionary using five lines of code. Then delete the first item. The keys are strings. The values are numbers. Make everything up. | syllables = { "fee": 1, "fi": 2, "fo": 3, } del syllables["fee"] | ^ *([a-zA-Z_][a-zA-Z0-9_]*) = {\n (•.+•): [-]?(?:[.]\d+|\d+(?:[.]\d*)?),\n •.+•: [-]?(?:[.]\d+|\d+(?:[.]\d*)?),\n •.+•: [-]?(?:[.]\d+|\d+(?:[.]\d*)?),\n}\ndel \1\[\2\] *$ | |
| af2e308242 | ||
| 1bf69d10ed |