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
When you read a CSV file in Python, you loop through it to turn it into a _______ | list | ^ *list *$ | |
You pick an element out of a list by specifying its ______ (one word) | index | ||
Complete the line to find the index number of "Bulgaria" in the list. | index_to_find = country_list.index_______________ | ("Bulgaria") | (`"`Bulgaria`"`) |
Complete the line to find the index number of "bat" in the list. | x = animals_________________ | .index("bat") | .index("bat") |
Complete the line to find the index of "vodka" in the drinks list. | i = _________________________________ | drinks.index("vodka") | ^ *drinks\.index\(•vodka•\) *$ |
Find the index of a string in a list and assign it to a variable. Make everything up. | target = drinks.index("vodka") | ^ *[a-zA-Z_][a-zA-Z0-9_]* = [a-zA-Z_][a-zA-Z0-9_]*\.index\(•.+•\) *$ | |
In a single line display the index of a string in a list. Make everything up. | print(drinks.index("gin")) | ^ *print\([a-zA-Z_][a-zA-Z0-9_]*\.index\(•.+•\)\) *$ | |
You're looking for the index of "Brian" in the following list, whose name is people. Write the first line. Make up the name of the variable that holds the index number. | ["First name","Last name","Age","Brian","Obst","36"] | target = people.index("Brian") | [a-zA-Z_][a-zA-Z0-9_]* = people.index\(•Brian•\) |
You're looking for Brian's age in the people list: ["First name","Last name","Age","Brian","Obst","36"]. Complete the second line using the variable from the first line. | target = people.index("Brian") targets_age_index = ____________ |
target + 2 | ^ *target \+ 2 *$ |
This is the people list: ["First name","Last name","Age","Brian","Obst","36"]. Code three lines that find the first name of the person named Obst and assign the first name to a variable. Make everything up. | index_of_last_name = people.index("Obst") index_of_first_name = index_of_last_name - 1 first_name = people[index_of_first_name] |
^ *([a-zA-Z_][a-zA-Z0-9_]*) = people\.index\(•Obst•\)\n([a-zA-Z_][a-zA-Z0-9_]*) = \1 - 1\n[a-zA-Z_][a-zA-Z0-9_]* = people\[\2\] *$ | |
|
|||