Diagnostic question: data types
Suppose you have the following datasets:
x = ['leopard', 'panther', 'pallas cat']
y = [1, 2, 3, 5, 8, 13]
z = [(1, 1), (4, 4), (9, 9), (16, 16)]
In order, what types of data are these?
- List, array, list of arrays
- List, list, list of tuples
- Array, array, array of tuples
- Ambiguous/could be multiple types
Summative question: indexing
Suppose you run the following code:
n = [[9, 8, 7], [6, 5, 4], [3, 2, 1]]
print n[2]
What gets printed?
- [6, 5, 4]
- 2
- 7
- [3, 2, 1]
Analysis:
- Those who choose (a) understand the structure of the list, but forget that Python indexing starts at 0.
- Those who choose (b) fail to understand that n[2] is selecting for the item with index 2 and not the value 2.
- Those who choose (c) understand that Python indexing starts at 0, but fail to understand how the list is structured.
- Correct