Merge pull request #123 from acharles7/alternate-Q16
Q16 Alternate Solution
This commit is contained in:
@@ -127,6 +127,11 @@ print(Z)
|
|||||||
Z = np.ones((5,5))
|
Z = np.ones((5,5))
|
||||||
Z = np.pad(Z, pad_width=1, mode='constant', constant_values=0)
|
Z = np.pad(Z, pad_width=1, mode='constant', constant_values=0)
|
||||||
print(Z)
|
print(Z)
|
||||||
|
|
||||||
|
# Using fancy indexing
|
||||||
|
Z[:, [0, -1]] = 0
|
||||||
|
Z[[0, -1], :] = 0
|
||||||
|
print(Z)
|
||||||
```
|
```
|
||||||
#### 17. What is the result of the following expression? (★☆☆)
|
#### 17. What is the result of the following expression? (★☆☆)
|
||||||
```python
|
```python
|
||||||
|
|||||||
@@ -127,6 +127,11 @@ print(Z)
|
|||||||
Z = np.ones((5,5))
|
Z = np.ones((5,5))
|
||||||
Z = np.pad(Z, pad_width=1, mode='constant', constant_values=0)
|
Z = np.pad(Z, pad_width=1, mode='constant', constant_values=0)
|
||||||
print(Z)
|
print(Z)
|
||||||
|
|
||||||
|
# Using fancy indexing
|
||||||
|
Z[:, [0, -1]] = 0
|
||||||
|
Z[[0, -1], :] = 0
|
||||||
|
print(Z)
|
||||||
```
|
```
|
||||||
#### 17. What is the result of the following expression? (★☆☆)
|
#### 17. What is the result of the following expression? (★☆☆)
|
||||||
```python
|
```python
|
||||||
|
|||||||
@@ -162,6 +162,11 @@ Z = np.ones((5,5))
|
|||||||
Z = np.pad(Z, pad_width=1, mode='constant', constant_values=0)
|
Z = np.pad(Z, pad_width=1, mode='constant', constant_values=0)
|
||||||
print(Z)
|
print(Z)
|
||||||
|
|
||||||
|
# Using fancy indexing
|
||||||
|
Z[:, [0, -1]] = 0
|
||||||
|
Z[[0, -1], :] = 0
|
||||||
|
print(Z)
|
||||||
|
|
||||||
< q17
|
< q17
|
||||||
What is the result of the following expression? (★☆☆)
|
What is the result of the following expression? (★☆☆)
|
||||||
```python
|
```python
|
||||||
|
|||||||
Reference in New Issue
Block a user