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
Targeting the correct element in the following list, assign "fi" to the variable giant_syllable. | giant_speak = ["fee", "fi", "fo", "fum"] | giant_syllable = giant_speak[1] | ^ *giant_syllable = giant_speak\[1\] *$ |
To target a value in a dictionary, you specify the dictionary name plus the item's _____. | key | ^ *key *$ | |
To target the dictionary item whose key is "age" complete this code: | customer_age = info__________ | ["age"] | [`"`age`"`] |
To target the dictionary item whose key is 100 complete this code: | winner_name = signups_______ | [100] | [100] |
Target the second item and assign its value to a variable. Make up the variable name. | cust = {"first name": "David", "last name": "Elliott", "address": "4803 Wellesley St."} | targeted_value = cust["last name"] | ^ *[a-zA-Z_][a-zA-Z0-9_]* = cust\[•last name•\] *$ |
Target an item in a dictionary whose key is a string. Assign the item's value to a variable. Make everything up. | x = y["name"] | ^ *[a-zA-Z_][a-zA-Z0-9_]* = [a-zA-Z_][a-zA-Z0-9_]*\[•.*•\] *$ | |
A dictionary's item key can be a string that contains spaces. Target an item in a dictionary whose key is a string that contains a space. Assign the item's value to a variable. Make everything up. | first_name = customer["first name"] | ^ *[a-zA-Z_][a-zA-Z0-9_]* = [a-zA-Z_][a-zA-Z0-9_]*\[•.* .*•\] *$ | |
Assign a dictionary item's value to a variable using a key that's a string. Then append that value to a list. Make everything up. | age = info["age"] list_of_ages.append(age) | ^ *([a-zA-Z_][a-zA-Z0-9_]*) = [a-zA-Z_][a-zA-Z0-9_]*\[•.*•\]\n[a-zA-Z_][a-zA-Z0-9_]*\.append\(\1\) *$ | |
Assign a dictionary item's value to a variable using a key that's a string. Then create a list that contains only that value. Make everything up. | value_to_get = dict["age"] new_list = [value_to_get] | ^ *([a-zA-Z_][a-zA-Z0-9_]*) = [a-zA-Z_][a-zA-Z0-9_]*\[•.*•\]\n[a-zA-Z_][a-zA-Z0-9_]* = \[\1\] *$ | |
Assign a dictionary item's value to a variable using a key that's a string. Then create a dictionary that contains only that value. Make everything up, including the key (a string) for the value in the new dictionary. | value_to_get = dict["age"] new_dictionary = {"transferred number": value_to_get} | ^ *([a-zA-Z_][a-zA-Z0-9_]*) = [a-zA-Z_][a-zA-Z0-9_]*\[•.*•\]\n[a-zA-Z_][a-zA-Z0-9_]* = {•.*•: \1} *$ | |
| 9c6804a8c6 | ||
| bb63555ef8 |