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
In this code, customer_29876 is a ______. (one word) | if "brother-in-law" in customer_29876["discounts"]: discount_amount = .30 elif "loyalty" in customer_29876["discounts"]: discount_amount = .15 |
dictionary | ^ *dictionary *$ |
In this code, "discounts" is a ______. (one word) | if "brother-in-law" in customer_29876["discounts"]: discount_amount = .30 elif "loyalty" in customer_29876["discounts"]: discount_amount = .15 |
list | ^ *list *$ |
To check whether "spanner" is in the "wrenches" list inside the tools dictionary, complete the line. | if "spanner" in ______________ | tools["wrenches"]: | tools`[`"`wrenches`"`]`: |
To check whether "weaving" is in the "electives" list inside the courses dictionary, complete the line. | if "weaving" in courses["electives"]: | if "weaving" in courses["electives"]: | |
Check whether "Mary" is in the "enrolled" list inside the students dictionary. | if "Mary" in students["enrolled"]: | ^ *if •Mary• in students\[•enrolled•\]: *$ | |
Check whether "Marx" is in a list within a dictionary. Make up the list and dictionary names. | if "Marx" in thinkers["left-wing"]: | ^ *if •Marx• in [a-zA-Z_][a-zA-Z0-9_]*\[•?.+•?\]: *$ | |
Test whether an integer is in a list within a dictionary. Make everything up. | if 666 in numbers["evil"]: | ^ *if -?[0-9]+ in [a-zA-Z_][a-zA-Z0-9_]*\[•?.+•?\]: *$ | |
Test whether "red" is in the list within the dictionary. | specs = { "colors": ["green", "blue", "purple"], } |
if "red" in specs["colors"]: | ^ *if •red• in specs\[•colors•\]: *$ |
Test whether a color is in the list within the dictionary. Make up the color. | specs = { "colors": ["green", "blue", "purple"], } |
if "red" in specs["colors"]: | ^ *if •.+• in specs\[•colors•\]: *$ |
Test whether a color is in the list within the dictionary. If so, display "first". If not, test whether another color is in the list. If so, display "second". Your choice of colors. | specs = { "colors": ["green", "blue", "purple"], } |
if "red" in specs["colors"]: print("first") elif "blue" in specs["colors"]: print("second") |
^ *if •.+• in specs\[•colors•\]:\n print\(•first•\)\nelif •.+• in specs\[•colors•\]:\n print\(•second•\) *$ |
|
affcf70b5d | ||
|
9345eb8a10 |