The first MCQ relates to the introductory (intermediate) lesson on Python programming from the v 5.2 lessons: 01-intro-python
You have a Pandas dataframe (assigned to the variable df
) with the following data:
index | year | temperature | rainfall | mosquitos |
---|---|---|---|---|
0 | 2001 | 80 | 157 | 150 |
1 | 2002 | 85 | 252 | 217 |
2 | 2003 | 86 | 154 | 153 |
3 | 2004 | 87 | 159 | 158 |
Which of the following code snippets will return the temperature and rainfall of rows 2 and 3?
df[['temperature','rainfall']][1:3]
df['temperature', 'rainfall'][1:3]
df.iloc[1:3]
df.iloc[1:3,1:2]
The second MCQ relates to the v 5.3 novice Python lesson and focuses on Python lists, which I also used for the concept map exercise.
You have the following list: myList = [42, 1, 0, 'moon']
. What output does the following code generate:
myList.reverse()
print myList[1], myList[-1]
42, 'moon'
1, 'moon'
0, 42
0, 1
Explanation:
Answer 1 should diagnose whether the student has understood that .reverse()
changes myList
and should indicate whether the student has picked up on that Python starts numbering with 0, and not 1.
Answer 2 is intended to distinguish between cases where the student understands how the numbering of elements works and what the index -1 refers to, but that it has not understood how the .reverse()
method works
Answer 3 is the correct answer
Answer 4 is to diagnose whether the student has understood how .reverse()
works but not which element the index -1 refers to.