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,11 +15,25 @@ videoId: v-7Y7koJ_N0
```yml
question:
text: Question
text: |
What code would change the values in the 3rd column of both of the following Numpy arrays to 20?:
```py
a = np.array([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]])
# Output:
# [[ 1 2 3 4 5]
# [ 6 7 20 9 10]]
```
answers:
- one
- two
- three
- |
`a[:, 3] = 20`
- |
`a[2, :] = 20`
- |
`a[:, 2] = 20`
- |
`a[1, 2] = 20`
solution: 3
```

View File

@ -15,7 +15,7 @@ videoId: f9QrZrKQMLI
```yml
question:
text: 'What will the following code print:<pre>b = np.array([[1.0,2.0,3.0],[3.0,4.0,5.0]])<br>print(b)</pre>'
text: 'What will the following code print?:<pre>b = np.array([[1.0,2.0,3.0],[3.0,4.0,5.0]])<br>print(b)</pre>'
answers:
- '<pre>[[1.0 2.0 3.0]<br>[3.0 4.0 5.0]]<pre>'
- '<pre>[[1. 2. 3.]<br>[3. 4. 5.]]<pre>'

View File

@ -15,12 +15,25 @@ videoId: iIoQ0_L0GvA
```yml
question:
text: Question
text: |
What is the value of `a` after running the following code?:
```py
import numpy as np
a = np.array([1, 2, 3, 4, 5])
b = a
b[2] = 20
```
answers:
- one
- two
- three
solution: 3
- |
`[1, 2, 3, 4, 5]`
- |
`[1, 2, 20, 4, 5]`
- |
`[1, 20, 3, 4, 5]`
solution: 2
```
</section>

View File

@ -15,12 +15,46 @@ videoId: 0jGfH8BPfOk
```yml
question:
text: Question
text: |
What is another way to produce the following array?:
```
[[1. 1. 1. 1. 1.]
[1. 0. 0. 0. 1.]
[1. 0. 9. 0. 1.]
[1. 0. 0. 0. 1.]
[1. 1. 1. 1. 1.]]
```
answers:
- one
- two
- three
solution: 3
- |
```py
output = np.ones((5, 5))
z = np.zeros((3, 3))
z[1, 1] = 9
output[1:-1, 1:-1] = z
```
- |
```py
output = np.ones((5, 5))
z = np.zeros((3, 3))
z[1, 1] = 9
output[1:3, 1:3] = z
```
- |
```py
output = np.ones((5, 5))
z = np.zeros((3, 3))
z[1, 1] = 9
output[4:1, 4:1] = z
```
solution: 1
```
</section>

View File

@ -15,12 +15,30 @@ videoId: CEykdsKT4U4
```yml
question:
text: Question
text: |
What will the following code print?:
```py
a = np.array([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]])
print(np.full_like(a, 100))
```
answers:
- one
- two
- three
solution: 3
- |
```
[[100 100 100 100 100]]
```
- |
```
[[100 100 100 100 100]
[100 100 100 100 100]]
```
- |
```
[[ 1 2 3 4 5]
[ 6 7 20 9 10]]
```
solution: 2
```
</section>

View File

@ -15,11 +15,42 @@ videoId: tUdBZ7pF8Jg
```yml
question:
text: Question
text: |
Given a file named `data.txt` with these contents:
```
29,97,32,100,45
15,88,5,75,22
```
What code would produce the following array?:
```py
[29. 32. 45. 15. 5. 22.]
```
answers:
- one
- two
- three
- |
```
filedata = np.genfromtxt('data.txt', delimiter=',')
output = np.any(filedata < 50)
print(output)
```
- |
```
filedata = np.genfromtxt('data.txt', delimiter=',')
output = np.all(filedata < 50, axis=1)
print(output)
```
- |
```
filedata = np.genfromtxt('data.txt', delimiter=',')
output = filedata[filedata < 50]
print(output)
```
solution: 3
```

View File

@ -15,12 +15,22 @@ videoId: 7txegvyhtVk
```yml
question:
text: Question
text: |
What is the value of `b` after running the following code?:
```py
import numpy as np
a = np.array(([1, 2, 3, 4, 5], [6, 7, 8, 9, 10]))
b = np.max(a, axis=1).sum()
```
answers:
- one
- two
- three
solution: 3
- '10'
- '7'
- '5'
- '15'
solution: 4
```
</section>

View File

@ -15,12 +15,35 @@ videoId: VNWAQbEM-C8
```yml
question:
text: Question
text: |
What code would produce the following array?:
```
[[1. 1.]
[1. 1.]
[1. 1.]
[1. 1.]]
```
answers:
- one
- two
- three
solution: 3
- |
```py
a = np.ones((2, 4))
b = a.reshape((4, 2))
print(b)
```
- |
```py
a = np.ones((2, 4))
b = a.reshape((2, 4))
print(b)
```
- |
```py
a = np.ones((2, 4))
b = a.reshape((8, 1))
print(b)
```
solution: 1
```
</section>

View File

@ -15,12 +15,13 @@ videoId: 5Nwfs5Ej85Q
```yml
question:
text: Question
text: 'Why are Numpy arrays faster than regular Python lists?:'
answers:
- one
- two
- three
solution: 3
- Numpy does not perform type checking while iterating through objects.
- Numpy uses fixed types.
- Numpy uses contiguous memory.
- All of the above.
solution: 4
```
</section>