copyright © 2017 by Mark Myers. All rights reserved.
What is players? (one word) |
players = ["Jane", "Jen", "Jill"] |
list | ^ *list *$ |
Type the two characters that are missing from this list definition. |
scores = 78, 47, 3, 52, 16 |
[] | ^ *\[\] *$ |
The last element in the list is 0. Complete the list definition. |
qtys = [144, 12, 16__________ |
, 0] |
, `0`] |
Define a list, noncolors, that has a single element, "black". |
| noncolors = ["black"] | noncolors = ["black"] |
What is the index number of a list's first element? |
|
0 |
^ *0 *$ |
A list contains 20 elements. What is the index number of the last element? |
|
19 |
^ *19 *$ |
Assign the third element in the list to a variable. Make up the variable name. |
cities = ["Atlanta", "Baltimore", "Chicago", "Denver", "Los Angeles", "Seattle"] |
third_on_list = cities[2] |
^ *[a-zA-Z_][a-zA-Z0-9_]* = cities\[2\] *$ |
Code a list whose three elements are integers. Make up the name of the list and the integers. |
|
signups = [9, 14, 19] |
^ *[a-zA-Z_][a-zA-Z0-9_]* = \[-?[0-9]+, -?[0-9]+, -?[0-9]+\] *$ |
Code a list whose two elements are strings. Make up the name of the list and the strings. |
|
cars = ["Tesla", "BMW"] |
^ *[a-zA-Z_][a-zA-Z0-9_]* = \[•.+•, •.+•\] *$ |
In a single line of code and using the list to specify the element, display "Black". |
seas = ["North", "Red", "Dead", "Black", "Baltic", "Bali"] |
print(seas[3]) |
^ *print\(seas\[3\]\) *$ |
- Complete line 2 to assign the last element of the list to the variable.
- Click the Run button
above your code. If you've coded correctly, Fri will display in the right-hand panel. (You can click Instructions at the top of the right-hand panel to see the correct code.) |
3e2c2ebc4b |
|
|
- Define a list that contains three elements.
- Display the list.
- Click the Run button
above your code. If you've coded correctly, the list will display in the right-hand panel. (You can click Instructions at the top of the right-hand panel to see the correct code.) |
556f295c81 | |
|