fix: QA/Infosec update and python to chinese

This commit is contained in:
Oliver Eyton-Williams
2020-08-13 12:00:20 +02:00
committed by Mrugesh Mohapatra
parent 2c78402837
commit 1cfa09adc4
861 changed files with 6847 additions and 0 deletions

View File

@ -0,0 +1,50 @@
---
id: 5e9a0a8e09c5df3cc3600ed4
title: Accessing and Changing Elements, Rows, Columns
challengeType: 11
isHidden: false
videoId: v-7Y7koJ_N0
---
## Description
<section id='description'>
</section>
## Tests
<section id='tests'>
````yml
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 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
````
</section>

View File

@ -0,0 +1,47 @@
---
id: 5e9a0a8e09c5df3cc3600ed3
title: Basics of Numpy
challengeType: 11
isHidden: false
videoId: f9QrZrKQMLI
---
## Description
<section id='description'>
</section>
## Tests
<section id='tests'>
````yml
question:
text: |
What will the following code print?
```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
````
</section>

View File

@ -0,0 +1,47 @@
---
id: 5e9a0a8e09c5df3cc3600ed7
title: Copying Arrays Warning
challengeType: 11
isHidden: false
videoId: iIoQ0_L0GvA
---
## Description
<section id='description'>
</section>
## Tests
<section id='tests'>
````yml
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:
- |
```python
[1 2 3 4 5]
```
- |
```python
[1 2 20 4 5]
```
- |
```python
[1 20 3 4 5]
```
solution: 2
````
</section>

View File

@ -0,0 +1,62 @@
---
id: 5e9a0a8e09c5df3cc3600ed6
title: Initialize Array Problem
challengeType: 11
isHidden: false
videoId: 0jGfH8BPfOk
---
## Description
<section id='description'>
</section>
## Tests
<section id='tests'>
````yml
question:
text: |
What is another way to produce the following array?
```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.]]
```
answers:
- |
```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

@ -0,0 +1,46 @@
---
id: 5e9a0a8e09c5df3cc3600ed5
title: Initializing Different Arrays
challengeType: 11
isHidden: false
videoId: CEykdsKT4U4
---
## Description
<section id='description'>
</section>
## Tests
<section id='tests'>
````yml
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:
- |
```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
````
</section>

View File

@ -0,0 +1,59 @@
---
id: 5e9a0a8e09c5df3cc3600eda
title: Loading Data and Advanced Indexing
challengeType: 11
isHidden: false
videoId: tUdBZ7pF8Jg
---
## Description
<section id='description'>
</section>
## Tests
<section id='tests'>
````yml
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:
- |
```py
filedata = np.genfromtxt('data.txt', delimiter=',')
output = np.any(filedata < 50)
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]
print(output)
```
solution: 3
````
</section>

View File

@ -0,0 +1,50 @@
---
id: 5e9a0a8e09c5df3cc3600ed8
title: Mathematics
challengeType: 11
isHidden: false
videoId: 7txegvyhtVk
---
## Description
<section id='description'>
</section>
## Tests
<section id='tests'>
````yml
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:
- |
```py
10
```
- |
```py
7
```
- |
```py
5
```
- |
```py
15
```
solution: 4
````
</section>

View File

@ -0,0 +1,51 @@
---
id: 5e9a0a8e09c5df3cc3600ed9
title: Reorganizing Arrays
challengeType: 11
isHidden: false
videoId: VNWAQbEM-C8
---
## Description
<section id='description'>
</section>
## Tests
<section id='tests'>
````yml
question:
text: |
What code would produce the following array?
```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
````
</section>

View File

@ -0,0 +1,35 @@
---
id: 5e9a0a8e09c5df3cc3600ed2
title: What is NumPy
challengeType: 11
isHidden: false
videoId: 5Nwfs5Ej85Q
---
## Description
<section id='description'>
</section>
## Tests
<section id='tests'>
```yml
question:
text: |
Why are Numpy arrays faster than regular Python lists?
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
```
</section>