chore(learn): Applied MDX format to Chinese curriculum files (#40462)
This commit is contained in:
@ -4,45 +4,50 @@ challengeType: 11
|
||||
videoId: v-7Y7koJ_N0
|
||||
---
|
||||
|
||||
## Description
|
||||
# --question--
|
||||
|
||||
<section id='description'>
|
||||
</section>
|
||||
## --text--
|
||||
|
||||
## Tests
|
||||
What code would change the values in the 3rd column of both of the following Numpy arrays to 20?
|
||||
|
||||
<section id='tests'>
|
||||
```py
|
||||
a = np.array([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]])
|
||||
|
||||
````yml
|
||||
question:
|
||||
text: |
|
||||
What code would change the values in the 3rd column of both of the following Numpy arrays to 20?
|
||||
# Output:
|
||||
# [[ 1 2 20 4 5]
|
||||
# [ 6 7 20 9 10]]
|
||||
```
|
||||
|
||||
```py
|
||||
a = np.array([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]])
|
||||
## --answers--
|
||||
|
||||
# Output:
|
||||
# [[ 1 2 20 4 5]
|
||||
# [ 6 7 20 9 10]]
|
||||
```
|
||||
answers:
|
||||
- |
|
||||
```python
|
||||
a[:, 3] = 20
|
||||
```
|
||||
- |
|
||||
```python
|
||||
a[2, :] = 20
|
||||
```
|
||||
- |
|
||||
```python
|
||||
a[:, 2] = 20
|
||||
```
|
||||
- |
|
||||
```python
|
||||
a[1, 2] = 20
|
||||
```
|
||||
solution: 3
|
||||
````
|
||||
```python
|
||||
a[:, 3] = 20
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```python
|
||||
a[2, :] = 20
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```python
|
||||
a[:, 2] = 20
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```python
|
||||
a[1, 2] = 20
|
||||
```
|
||||
|
||||
## --video-solution--
|
||||
|
||||
3
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
# --solutions--
|
||||
|
||||
</section>
|
||||
|
@ -4,42 +4,45 @@ challengeType: 11
|
||||
videoId: f9QrZrKQMLI
|
||||
---
|
||||
|
||||
## Description
|
||||
# --question--
|
||||
|
||||
<section id='description'>
|
||||
</section>
|
||||
## --text--
|
||||
|
||||
## Tests
|
||||
What will the following code print?
|
||||
|
||||
<section id='tests'>
|
||||
```python
|
||||
b = np.array([[1.0,2.0,3.0],[3.0,4.0,5.0]])
|
||||
print(b)
|
||||
```
|
||||
|
||||
````yml
|
||||
question:
|
||||
text: |
|
||||
What will the following code print?
|
||||
## --answers--
|
||||
|
||||
```python
|
||||
b = np.array([[1.0,2.0,3.0],[3.0,4.0,5.0]])
|
||||
print(b)
|
||||
```
|
||||
answers:
|
||||
- |
|
||||
```python
|
||||
[[1.0 2.0 3.0]
|
||||
[3.0 4.0 5.0]]
|
||||
```
|
||||
- |
|
||||
```python
|
||||
[[1. 2. 3.]
|
||||
[3. 4. 5.]]
|
||||
```
|
||||
- |
|
||||
```python
|
||||
[[1. 3.]
|
||||
[2. 4.]
|
||||
[3. 5.]
|
||||
```
|
||||
solution: 2
|
||||
````
|
||||
```python
|
||||
[[1.0 2.0 3.0]
|
||||
[3.0 4.0 5.0]]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```python
|
||||
[[1. 2. 3.]
|
||||
[3. 4. 5.]]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```python
|
||||
[[1. 3.]
|
||||
[2. 4.]
|
||||
[3. 5.]
|
||||
```
|
||||
|
||||
## --video-solution--
|
||||
|
||||
2
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
# --solutions--
|
||||
|
||||
</section>
|
||||
|
@ -4,42 +4,44 @@ challengeType: 11
|
||||
videoId: iIoQ0_L0GvA
|
||||
---
|
||||
|
||||
## Description
|
||||
# --question--
|
||||
|
||||
<section id='description'>
|
||||
</section>
|
||||
## --text--
|
||||
|
||||
## Tests
|
||||
What is the value of `a` after running the following code?
|
||||
|
||||
<section id='tests'>
|
||||
```py
|
||||
import numpy as np
|
||||
|
||||
````yml
|
||||
question:
|
||||
text: |
|
||||
What is the value of `a` after running the following code?
|
||||
a = np.array([1, 2, 3, 4, 5])
|
||||
b = a
|
||||
b[2] = 20
|
||||
```
|
||||
|
||||
```py
|
||||
import numpy as np
|
||||
## --answers--
|
||||
|
||||
a = np.array([1, 2, 3, 4, 5])
|
||||
b = a
|
||||
b[2] = 20
|
||||
```
|
||||
```python
|
||||
[1 2 3 4 5]
|
||||
```
|
||||
|
||||
answers:
|
||||
- |
|
||||
```python
|
||||
[1 2 3 4 5]
|
||||
```
|
||||
- |
|
||||
```python
|
||||
[1 2 20 4 5]
|
||||
```
|
||||
- |
|
||||
```python
|
||||
[1 20 3 4 5]
|
||||
```
|
||||
solution: 2
|
||||
````
|
||||
---
|
||||
|
||||
```python
|
||||
[1 2 20 4 5]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```python
|
||||
[1 20 3 4 5]
|
||||
```
|
||||
|
||||
## --video-solution--
|
||||
|
||||
2
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
# --solutions--
|
||||
|
||||
</section>
|
||||
|
@ -4,57 +4,59 @@ challengeType: 11
|
||||
videoId: 0jGfH8BPfOk
|
||||
---
|
||||
|
||||
## Description
|
||||
# --question--
|
||||
|
||||
<section id='description'>
|
||||
</section>
|
||||
## --text--
|
||||
|
||||
## Tests
|
||||
What is another way to produce the following array?
|
||||
|
||||
<section id='tests'>
|
||||
```py
|
||||
[[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.]]
|
||||
```
|
||||
|
||||
````yml
|
||||
question:
|
||||
text: |
|
||||
What is another way to produce the following array?
|
||||
## --answers--
|
||||
|
||||
```py
|
||||
[[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.]]
|
||||
```
|
||||
```py
|
||||
output = np.ones((5, 5))
|
||||
|
||||
answers:
|
||||
- |
|
||||
```py
|
||||
output = np.ones((5, 5))
|
||||
z = np.zeros((3, 3))
|
||||
z[1, 1] = 9
|
||||
|
||||
z = np.zeros((3, 3))
|
||||
z[1, 1] = 9
|
||||
output[1:-1, 1:-1] = z
|
||||
```
|
||||
|
||||
output[1:-1, 1:-1] = z
|
||||
```
|
||||
- |
|
||||
```py
|
||||
output = np.ones((5, 5))
|
||||
---
|
||||
|
||||
z = np.zeros((3, 3))
|
||||
z[1, 1] = 9
|
||||
```py
|
||||
output = np.ones((5, 5))
|
||||
|
||||
output[1:3, 1:3] = z
|
||||
```
|
||||
- |
|
||||
```py
|
||||
output = np.ones((5, 5))
|
||||
z = np.zeros((3, 3))
|
||||
z[1, 1] = 9
|
||||
|
||||
z = np.zeros((3, 3))
|
||||
z[1, 1] = 9
|
||||
output[1:3, 1:3] = z
|
||||
```
|
||||
|
||||
output[4:1, 4:1] = z
|
||||
```
|
||||
solution: 1
|
||||
````
|
||||
---
|
||||
|
||||
```py
|
||||
output = np.ones((5, 5))
|
||||
|
||||
z = np.zeros((3, 3))
|
||||
z[1, 1] = 9
|
||||
|
||||
output[4:1, 4:1] = z
|
||||
```
|
||||
|
||||
## --video-solution--
|
||||
|
||||
1
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
# --solutions--
|
||||
|
||||
</section>
|
||||
|
@ -4,41 +4,44 @@ challengeType: 11
|
||||
videoId: CEykdsKT4U4
|
||||
---
|
||||
|
||||
## Description
|
||||
# --question--
|
||||
|
||||
<section id='description'>
|
||||
</section>
|
||||
## --text--
|
||||
|
||||
## Tests
|
||||
What will the following code print?
|
||||
|
||||
<section id='tests'>
|
||||
```py
|
||||
a = np.array([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]])
|
||||
|
||||
````yml
|
||||
question:
|
||||
text: |
|
||||
What will the following code print?
|
||||
print(np.full_like(a, 100))
|
||||
```
|
||||
|
||||
```py
|
||||
a = np.array([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]])
|
||||
## --answers--
|
||||
|
||||
print(np.full_like(a, 100))
|
||||
```
|
||||
answers:
|
||||
- |
|
||||
```py
|
||||
[[100 100 100 100 100]]
|
||||
```
|
||||
- |
|
||||
```py
|
||||
[[100 100 100 100 100]
|
||||
[100 100 100 100 100]]
|
||||
```
|
||||
- |
|
||||
```py
|
||||
[[ 1 2 3 4 5]
|
||||
[ 6 7 20 9 10]]
|
||||
```
|
||||
solution: 2
|
||||
````
|
||||
```py
|
||||
[[100 100 100 100 100]]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```py
|
||||
[[100 100 100 100 100]
|
||||
[100 100 100 100 100]]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```py
|
||||
[[ 1 2 3 4 5]
|
||||
[ 6 7 20 9 10]]
|
||||
```
|
||||
|
||||
## --video-solution--
|
||||
|
||||
2
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
# --solutions--
|
||||
|
||||
</section>
|
||||
|
@ -4,54 +4,56 @@ challengeType: 11
|
||||
videoId: tUdBZ7pF8Jg
|
||||
---
|
||||
|
||||
## Description
|
||||
# --question--
|
||||
|
||||
<section id='description'>
|
||||
</section>
|
||||
## --text--
|
||||
|
||||
## Tests
|
||||
Given a file named `data.txt` with these contents:
|
||||
|
||||
<section id='tests'>
|
||||
```
|
||||
29,97,32,100,45
|
||||
15,88,5,75,22
|
||||
```
|
||||
|
||||
````yml
|
||||
question:
|
||||
text: |
|
||||
Given a file named `data.txt` with these contents:
|
||||
What code would produce the following array?
|
||||
|
||||
```
|
||||
29,97,32,100,45
|
||||
15,88,5,75,22
|
||||
```
|
||||
```py
|
||||
[29. 32. 45. 15. 5. 22.]
|
||||
```
|
||||
|
||||
What code would produce the following array?
|
||||
## --answers--
|
||||
|
||||
```py
|
||||
[29. 32. 45. 15. 5. 22.]
|
||||
```
|
||||
```py
|
||||
filedata = np.genfromtxt('data.txt', delimiter=',')
|
||||
output = np.any(filedata < 50)
|
||||
|
||||
answers:
|
||||
- |
|
||||
```py
|
||||
filedata = np.genfromtxt('data.txt', delimiter=',')
|
||||
output = np.any(filedata < 50)
|
||||
print(output)
|
||||
```
|
||||
|
||||
print(output)
|
||||
```
|
||||
- |
|
||||
```py
|
||||
filedata = np.genfromtxt('data.txt', delimiter=',')
|
||||
output = np.all(filedata < 50, axis=1)
|
||||
---
|
||||
|
||||
print(output)
|
||||
```
|
||||
- |
|
||||
```py
|
||||
filedata = np.genfromtxt('data.txt', delimiter=',')
|
||||
output = filedata[filedata < 50]
|
||||
```py
|
||||
filedata = np.genfromtxt('data.txt', delimiter=',')
|
||||
output = np.all(filedata < 50, axis=1)
|
||||
|
||||
print(output)
|
||||
```
|
||||
solution: 3
|
||||
````
|
||||
print(output)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```py
|
||||
filedata = np.genfromtxt('data.txt', delimiter=',')
|
||||
output = filedata[filedata < 50]
|
||||
|
||||
print(output)
|
||||
```
|
||||
|
||||
## --video-solution--
|
||||
|
||||
3
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
# --solutions--
|
||||
|
||||
</section>
|
||||
|
@ -4,45 +4,49 @@ challengeType: 11
|
||||
videoId: 7txegvyhtVk
|
||||
---
|
||||
|
||||
## Description
|
||||
# --question--
|
||||
|
||||
<section id='description'>
|
||||
</section>
|
||||
## --text--
|
||||
|
||||
## Tests
|
||||
What is the value of `b` after running the following code?
|
||||
|
||||
<section id='tests'>
|
||||
```py
|
||||
import numpy as np
|
||||
|
||||
````yml
|
||||
question:
|
||||
text: |
|
||||
What is the value of `b` after running the following code?
|
||||
a = np.array(([1, 2, 3, 4, 5], [6, 7, 8, 9, 10]))
|
||||
b = np.max(a, axis=1).sum()
|
||||
```
|
||||
|
||||
```py
|
||||
import numpy as np
|
||||
## --answers--
|
||||
|
||||
a = np.array(([1, 2, 3, 4, 5], [6, 7, 8, 9, 10]))
|
||||
b = np.max(a, axis=1).sum()
|
||||
```
|
||||
```py
|
||||
10
|
||||
```
|
||||
|
||||
answers:
|
||||
- |
|
||||
```py
|
||||
10
|
||||
```
|
||||
- |
|
||||
```py
|
||||
7
|
||||
```
|
||||
- |
|
||||
```py
|
||||
5
|
||||
```
|
||||
- |
|
||||
```py
|
||||
15
|
||||
```
|
||||
solution: 4
|
||||
````
|
||||
---
|
||||
|
||||
```py
|
||||
7
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```py
|
||||
5
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
```py
|
||||
15
|
||||
```
|
||||
|
||||
## --video-solution--
|
||||
|
||||
4
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
# --solutions--
|
||||
|
||||
</section>
|
||||
|
@ -4,46 +4,49 @@ challengeType: 11
|
||||
videoId: VNWAQbEM-C8
|
||||
---
|
||||
|
||||
## Description
|
||||
# --question--
|
||||
|
||||
<section id='description'>
|
||||
</section>
|
||||
## --text--
|
||||
|
||||
## Tests
|
||||
What code would produce the following array?
|
||||
|
||||
<section id='tests'>
|
||||
```py
|
||||
[[1. 1.]
|
||||
[1. 1.]
|
||||
[1. 1.]
|
||||
[1. 1.]]
|
||||
```
|
||||
|
||||
````yml
|
||||
question:
|
||||
text: |
|
||||
What code would produce the following array?
|
||||
## --answers--
|
||||
|
||||
```py
|
||||
[[1. 1.]
|
||||
[1. 1.]
|
||||
[1. 1.]
|
||||
[1. 1.]]
|
||||
```
|
||||
answers:
|
||||
- |
|
||||
```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
|
||||
````
|
||||
```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)
|
||||
```
|
||||
|
||||
## --video-solution--
|
||||
|
||||
1
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
# --solutions--
|
||||
|
||||
</section>
|
||||
|
@ -4,30 +4,34 @@ challengeType: 11
|
||||
videoId: 5Nwfs5Ej85Q
|
||||
---
|
||||
|
||||
## Description
|
||||
# --question--
|
||||
|
||||
<section id='description'>
|
||||
</section>
|
||||
## --text--
|
||||
|
||||
## Tests
|
||||
Why are Numpy arrays faster than regular Python lists?
|
||||
|
||||
<section id='tests'>
|
||||
## --answers--
|
||||
|
||||
```yml
|
||||
question:
|
||||
text: |
|
||||
Why are Numpy arrays faster than regular Python lists?
|
||||
Numpy does not perform type checking while iterating through objects.
|
||||
|
||||
answers:
|
||||
- |
|
||||
Numpy does not perform type checking while iterating through objects.
|
||||
- |
|
||||
Numpy uses fixed types.
|
||||
- |
|
||||
Numpy uses contiguous memory.
|
||||
- |
|
||||
All of the above.
|
||||
solution: 4
|
||||
```
|
||||
---
|
||||
|
||||
Numpy uses fixed types.
|
||||
|
||||
---
|
||||
|
||||
Numpy uses contiguous memory.
|
||||
|
||||
---
|
||||
|
||||
All of the above.
|
||||
|
||||
## --video-solution--
|
||||
|
||||
4
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
# --solutions--
|
||||
|
||||
</section>
|
||||
|
Reference in New Issue
Block a user