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
Get an element in a list and assign it to a variable. Make everything up. | the_element = a_list[7] | ^ *[a-zA-Z_][a-zA-Z0-9_]* = [a-zA-Z_][a-zA-Z0-9_]*\[-?[0-9]+\] *$ | |
Get a value in a dictionary and assign it to a variable. The key is a string. | price_to_get = product_3278["price"] | ^ *[a-zA-Z_][a-zA-Z0-9_]* = [a-zA-Z_][a-zA-Z0-9_]*\[•.+•\] *$ | |
In a single line, display the element in the animals whose index is 3. | print(animals[3]) | print`(`animals`[`3`]`) | |
In a single line, display the value in the animals dictionary's whose key is "wings". | print(animals["wings"]) | print(animals["wings"]) | |
The animals list contains dictionaries. Get a value out of dictionary 76 and assign it to a variable. The key is "name". Make up the variable name. | targeted_name = animals[76]["name"] | ^ *[a-zA-Z_][a-zA-Z0-9_]* = animals\[76\]\[•name•\] *$ | |
The animals dictionary contains lists. Get an element out of the "9" list that has an index of 0 and assign it to a variable. Make up the variable name. | target = animals["9"][0] | ^ *[a-zA-Z_][a-zA-Z0-9_]* = animals\[•9•\]\[0\] *$ | |
The dictionary flowers contains a dictionary whose name is 43. Get the value out of the dictionary whose key is a string and assign it to a variable. Make up the names of the key and the variable. | target = flowers[43]["annual"] | ^ *[a-zA-Z_][a-zA-Z0-9_]* = flowers\[43\]\[•.+•\] *$ | |
The dictionary students contains a dictionary whose name is 340. Get the value out of the dictionary whose key is a number and assign it to a variable. Make up the names of the key and the variable. | course = students[340][3] | ^ *[a-zA-Z_][a-zA-Z0-9_]* = students\[340\]\[-?[0-9]+\] *$ | |
Find the number of pairs in the students dictionary and assign the number to a variable. Make up the variable name. | enrollment = len(students) | ^ *[a-zA-Z_][a-zA-Z0-9_]* = len\(students\) *$ | |
The dictionary students contains a dictionary whose name is 340. Find the number of pairs in the 340 dictionary and assign the number to a variable. Make up the variable name. | target = len(students[340]) | ^ *[a-zA-Z_][a-zA-Z0-9_]* = len\(students\[340\]\) *$ | |
|
4bfa2a7aef | ||
|
ace675b061 |