feat(curriculum): add python multiple choice questions (#38890)

This commit is contained in:
Kristofer Koishigawa
2020-05-28 22:40:36 +09:00
committed by GitHub
parent 18d2dca05b
commit 3567813c51
98 changed files with 1118 additions and 398 deletions

View File

@ -15,7 +15,8 @@ videoId: mHjxzFS5_Z0
```yml
question:
text: 'When using Matplotlib''s global API, what does the order of numbers mean here <pre>plt.subplot(1, 2, 1)</pre>'
text: |
When using Matplotlib's global API, what does the order of numbers mean here?: `plt.subplot(1, 2, 1)`
answers:
- 'My figure will have one column, two rows, and I am going to start drawing in the first (left) plot.'
- 'I am going to start drawing in the first (left) plot, my figure will have two rows, and my figure will have one column.'

View File

@ -15,7 +15,8 @@ videoId: kj7QqjXhH6A
```yml
question:
text: 'The Python method <code>.duplicated()</code> returns a boolean Series for your DataFrame. <code>True</code> is the return value for rows that:'
text: |
The Python method `.duplicated()` returns a boolean Series for your DataFrame. `True` is the return value for rows that:
answers:
- contain a duplicate, where the value for the row contains the first occurrence of that value.
- contain a duplicate, where the value for the row is at least the second occurrence of that value.

View File

@ -15,12 +15,39 @@ videoId: ovYNhnltVxY
```yml
question:
text: Question
text: |
What will the following code print out?:
```py
import pandas as pd
import numpy as np
s = pd.Series(['a', 3, np.nan, 1, np.nan])
print(s.notnull().sum())
```
answers:
- one
- two
- three
solution: 3
- '3'
- |
```
0 True
1 True
2 False
3 True
4 False
dtype: bool
```
- |
```
0 False
1 False
2 True
3 False
4 True
dtype: bool
```
solution: 1
```
</section>

View File

@ -15,12 +15,48 @@ videoId: sTMN_pdI6S0
```yml
question:
text: Question
text: |
What will the following code print out?:
```py
import pandas as pd
import numpy as np
s = pd.Series([np.nan, 1, 2, np.nan, 3])
s = s.fillna(method='ffill')
print(s)
```
answers:
- one
- two
- three
solution: 3
- |
```
0 1.0
1 1.0
2 2.0
3 3.0
4 3.0
dtype: float64
```
- |
```
0 NaN
1 1.0
2 2.0
3 2.0
4 3.0
dtype: float64
```
- |
```
0 NaN
1 1.0
2 2.0
3 NaN
4 3.0
dtype: float64
```
solution: 2
```
</section>

View File

@ -15,11 +15,11 @@ videoId: h8caJq2Bb9w
```yml
question:
text: Question
text: What is *not* allowed in a Jupyter Notebook's cell?
answers:
- one
- two
- three
- "Markdown"
- "Python code"
- "An Excel sheet"
solution: 3
```

View File

@ -15,12 +15,13 @@ videoId: VJrP2FUzKP0
```yml
question:
text: Question
text: "Why should you choose R over Python for data analysis?"
answers:
- one
- two
- three
solution: 3
- "It's simple to learn."
- "It's better at dealing with advanced statistical methods."
- "There are many powerful libraries that support R."
- "It's free and open source."
solution: 2
```
</section>

View File

@ -15,12 +15,14 @@ videoId: k1msxD3JIxE
```yml
question:
text: Question
text: "What kind of data can you import and work with in a Jupyter Notebook?"
answers:
- one
- two
- three
solution: 3
- "Excel files."
- "CSV files."
- "XML files."
- "Data from an API."
- "All of the above."
solution: 5
```
</section>

View File

@ -15,11 +15,33 @@ videoId: VDYVFHBL1AM
```yml
question:
text: Question
text: |
What will the following code print out?:
```py
A = np.array([
['a', 'b', 'c'],
['d', 'e', 'f'],
['g', 'h', 'i']
])
print(A[:, :2])
```
answers:
- one
- two
- three
- "[['a' 'b']]"
- |
```
[['b' 'c']
['e' 'f']
['h' 'i']]
```
- |
```
[['a' 'b']
['d' 'e']
['g' 'h']]
```
solution: 3
```

View File

@ -15,12 +15,20 @@ videoId: N1ttsMmcVMM
```yml
question:
text: Question
text: |
What will the following code print out?:
```py
a = np.arange(5)
print(a <= 3)
```
answers:
- one
- two
- three
solution: 3
- "[False, False, False, False, True]"
- "[5]"
- "[0, 1, 2, 3]"
- "[True, True, True, True, False]"
solution: 4
```
</section>

View File

@ -15,12 +15,12 @@ videoId: P-JjV6GBCmk
```yml
question:
text: Question
text: "Why is Numpy an important, but unpopular Python library?"
answers:
- one
- two
- three
solution: 3
- "Often you won't work directly with Numpy."
- "It's is extremely slow."
- "Working with Numpy is difficult."
solution: 1
```
</section>

View File

@ -15,12 +15,14 @@ videoId: YIqgrNLAZkA
```yml
question:
text: Question
text: |
About how much memory does the integer `5` consume in plain Python?
answers:
- one
- two
- three
solution: 3
- 32 bits
- 20 bytes
- 16 bytes
- 8 bits
solution: 2
```
</section>

View File

@ -15,12 +15,19 @@ videoId: eqSVcJbaPdk
```yml
question:
text: Question
text: |
What is the value of `a` after you run the following code?:
```py
a = np.arange(5)
a + 20
```
answers:
- one
- two
- three
solution: 3
- "[20, 21, 22, 24, 24]"
- "[0, 1, 2, 3, 4, 5]"
- "[25, 26, 27, 28, 29]"
solution: 2
```
</section>

View File

@ -15,12 +15,51 @@ videoId: BFlH0fN5xRQ
```yml
question:
text: Question
text: |
What will the following code print out?:
```py
import pandas as pd
certificates_earned = pd.DataFrame({
'Certificates': [8, 2, 5, 6],
'Time (in months)': [16, 5, 9, 12]
})
names = ['Tom', 'Kris', 'Ahmad', 'Beau']
certificates_earned.index = names
longest_streak = pd.Series([13, 11, 9, 7], index=names)
certificates_earned['Longest streak'] = longest_streak
print(certificates_earned)
```
answers:
- one
- two
- three
solution: 3
- |
```
Tom 13
Kris 11
Ahmad 9
Beau 7
Name: Longest streak, dtype: int64
```
- |
```
Certificates Time (in months) Longest streak
Tom 8 16 13
Kris 2 5 11
Ahmad 5 9 9
Beau 6 12 7
```
- |
```
Certificates Longest streak
Tom 8 13
Kris 2 11
Ahmad 5 9
Beau 6 7
```
solution: 2
```
</section>

View File

@ -15,11 +15,37 @@ videoId: _sSo2XZoB3E
```yml
question:
text: Question
text: |
What code would add a "Certificates per month" column to the `certificates_earned` DataFrame like the one below?:
```
Certificates Time (in months) Certificates per month
Tom 8 16 0.50
Kris 2 5 0.40
Ahmad 5 9 0.56
Beau 6 12 0.50
```
answers:
- one
- two
- three
- |
```py
certificates_earned['Certificates'] /
certificates_earned['Time (in months)']
```
- |
```py
certificates_earned['Certificates per month'] = round(
certificates_earned['Certificates'] /
certificates_earned['Time (in months)']
)
```
- |
```py
certificates_earned['Certificates per month'] = round(
certificates_earned['Certificates'] /
certificates_earned['Time (in months)'], 2
)
```
solution: 3
```

View File

@ -15,11 +15,43 @@ videoId: 7SgFBYXaiH0
```yml
question:
text: Question
text: |
What will the following code print out?:
```py
import pandas as pd
certificates_earned = pd.DataFrame({
'Certificates': [8, 2, 5, 6],
'Time (in months)': [16, 5, 9, 12]
})
certificates_earned.index = ['Tom', 'Kris', 'Ahmad', 'Beau']
print(certificates_earned.iloc[2])
```
answers:
- one
- two
- three
- |
```
Tom 16
Kris 5
Ahmad 9
Beau 12
Name: Time (in months), dtype: int64
```
- |
```
Certificates 6
Time (in months) 12
Name: Beau, dtype: int64
```
- |
```
Certificates 5
Time (in months) 9
Name: Ahmad, dtype: int64
```
solution: 3
```

View File

@ -15,11 +15,42 @@ videoId: -ZOrgV_aA9A
```yml
question:
text: Question
text: |
What will the following code print out?:
```py
import pandas as pd
certificates_earned = pd.Series(
[8, 2, 5, 6],
index=['Tom', 'Kris', 'Ahmad', 'Beau']
)
print(certificates_earned[certificates_earned > 5])
```
answers:
- one
- two
- three
- |
```
Tom True
Kris False
Ahmad False
Beau True
dtype: int64
```
- |
```
Tom 8
Ahmad 5
Beau 6
dtype: int64
```
- |
```
Tom 8
Beau 6
dtype: int64
```
solution: 3
```

View File

@ -15,12 +15,46 @@ videoId: 0xACW-8cZU0
```yml
question:
text: Question
text: |
What will the following code print out?:
```py
import pandas as pd
certificates_earned = pd.Series(
[8, 2, 5, 6],
index=['Tom', 'Kris', 'Ahmad', 'Beau']
)
print(certificates_earned)
```
answers:
- one
- two
- three
solution: 3
- |
```
Tom 8
Kris 2
Ahmad 5
Beau 6
dtype: int64
```
- |
```
Kris 2
Ahmad 5
Beau 6
Tom 8
dtype: int64
```
- |
```
Tom 8
Kris 2
Ahmad 5
Beau 6
Name: certificates_earned dtype: int64
```
solution: 1
```
</section>

View File

@ -15,12 +15,12 @@ videoId: NzpU17ZVlUw
```yml
question:
text: Question
text: What is the main difference between lists and tuples in Python?
answers:
- one
- two
- three
solution: 3
- Tuples are immutable.
- Lists are ordered.
- Tuples are unordered.
solution: 1
```
</section>

View File

@ -17,9 +17,9 @@ videoId: MtgXS1MofRw
question:
text: What method does a <code>Cursor</code> instance have and what does it allow?
answers:
- The <code>Cursor</code> instance has a <code>.Run()</code> method which allows you to run SQL queries.
- The <code>Cursor</code> instance has a <code>.Select()</code> method which allows you to select records.
- The <code>Cursor</code> instance has a <code>.Execute()</code> method which will receive SQL parameters to run against the database.
- The <code>Cursor</code> instance has a <code>.run()</code> method which allows you to run SQL queries.
- The <code>Cursor</code> instance has a <code>.select()</code> method which allows you to select records.
- The <code>Cursor</code> instance has an <code>.execute()</code> method which will receive SQL parameters to run against the database.
solution: 3
```

View File

@ -15,12 +15,35 @@ videoId: cDnt02BcHng
```yml
question:
text: Question
text: |
Given a file named `certificates.csv` with these contents:
```
Name$Certificates$Time (in months)
Tom$8$16
Kris$2$5
Ahmad$5$9
Beau$6$12
```
Fill in the blanks for the missing arguments below:
```py
import csv
with open(___, 'r') as fp:
reader = csv.reader(fp, delimiter=___)
next(reader)
for index, values in enumerate(reader):
name, certs_num, months_num = values
print(f"{name} earned {___} certificates in {months_num} months")
```
answers:
- one
- two
- three
solution: 3
- <code>'certificates.csv', '-', values</code>
- <code>'certificates.csv', '$', certs_num</code>
- <code>'certificates', '$', certs_num</code>
solution: 2
```
</section>