I made my multiple choice questions based on the material from the first python lesson.
Q1. Consider the following code:
a = 7
b = a + 3
a = 2
What does b equal?
A. 5
B. 10
C. 73
D. a3
Q2. If you have a numpy array, in a variable bats
, how would you access the data item at the 5th column, 2nd row?
A. bats[2,5]
B. bats(1,4)
C. bats[1,4]
D. bats[4,1]
- C is the correct answer.
- A is the answer they would get if they were indexing from 1 instead of 0
- B is the answer if they where mixing up round brackets, which call functions, and square brackets which access a element of an iterable.
- D is if they mix up that indexing is [row, column], not [column, row].