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
Type the two characters that are missing from this dictionary definition. | dictionary_of_capitals = "Thailand": "Bangkok", "Mexico": "Mexico City", "Canada": "Ottawa" | {} | ^ *{ *} *$ |
Type the character that is missing from this dictionary definition. It's missing three times, but type it just once. | dictionary_of_capitals = {"Thailand" "Bangkok", "Mexico" "Mexico City", "Canada" "Ottawa"} | : | ^ *: *$ |
Code a list named colors. The elements are "red" and "blue". | colors = ["red", "blue"] | colors `= `[`"`red`"`, `"`blue`"`] | |
Code a dictionary named relatives. It has only one item. "brother" is paired with "Bob" | relatives = {"brother": "Bob"} | relatives = {"brother": "Bob"} | |
Code an empty dictionary. Make up the name of the dictionary. | cities = {} | ^ *[a-zA-Z_][a-zA-Z0-9_]* = {} *$ | |
A dictionary contains pairs. A key is paired with a ______. | value | ^ *value *$ | |
A dictionary contains pairs. A _____ is paired with a value. | key | ^ *key *$ | |
Define a dictionary with two items. The keys are "population" and "life_expectancy". The values are numbers. Make up the dictionary name and the values. | stats = {"population": 20786, "life_expectancy": 64} | ^ *[a-zA-Z_][a-zA-Z0-9_]* = {•population•: [-]?(?:[.]\d+|\d+(?:[.]\d*)?), •life_expectancy•: [-]?(?:[.]\d+|\d+(?:[.]\d*)?)} *$ | |
Code a dictionary with two key-value pairs. The keys are numbers. The values are strings. Make up the dictionary name, the keys, and the values. | number_names = {3: "three", 4: "four"} | ^ *[a-zA-Z_][a-zA-Z0-9_]* = {[-]?(?:[.]\d+|\d+(?:[.]\d*)?): •.*•, [-]?(?:[.]\d+|\d+(?:[.]\d*)?): •.*•} *$ | |
Code a dictionary with two key-value pairs. The keys are strings. The values are numbers. Make up the dictionary name, the keys, and the values. | info = {"age": 26, "income": 33500} | ^ *[a-zA-Z_][a-zA-Z0-9_]* = {•.*•: [-]?(?:[.]\d+|\d+(?:[.]\d*)?), •.*•: [-]?(?:[.]\d+|\d+(?:[.]\d*)?)} *$ | |
| c508aacf94 | ||
| 3e0b3ebc98 |