add difficulty
This commit is contained in:
parent
22f47a6e0b
commit
8603114b95
File diff suppressed because it is too large
Load Diff
@ -58,7 +58,7 @@ np.nan in set([np.nan])
|
|||||||
|
|
||||||
#### 19. Create a 8x8 matrix and fill it with a checkerboard pattern (★☆☆)
|
#### 19. Create a 8x8 matrix and fill it with a checkerboard pattern (★☆☆)
|
||||||
|
|
||||||
#### 20. Consider a (6,7,8) shape array, what is the index (x,y,z) of the 100th element?
|
#### 20. Consider a (6,7,8) shape array, what is the index (x,y,z) of the 100th element? (★☆☆)
|
||||||
|
|
||||||
#### 21. Create a checkerboard 8x8 matrix using the tile function (★☆☆)
|
#### 21. Create a checkerboard 8x8 matrix using the tile function (★☆☆)
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ Z/1/1
|
|||||||
Z<Z>Z
|
Z<Z>Z
|
||||||
```
|
```
|
||||||
|
|
||||||
#### 28. What are the result of the following expressions?
|
#### 28. What are the result of the following expressions? (★☆☆)
|
||||||
```python
|
```python
|
||||||
np.array(0) / np.array(0)
|
np.array(0) / np.array(0)
|
||||||
np.array(0) // np.array(0)
|
np.array(0) // np.array(0)
|
||||||
@ -135,7 +135,7 @@ np.sqrt(-1) == np.emath.sqrt(-1)
|
|||||||
|
|
||||||
#### 46. Create a structured array with `x` and `y` coordinates covering the [0,1]x[0,1] area (★★☆)
|
#### 46. Create a structured array with `x` and `y` coordinates covering the [0,1]x[0,1] area (★★☆)
|
||||||
|
|
||||||
#### 47. Given two arrays, X and Y, construct the Cauchy matrix C (Cij =1/(xi - yj))
|
#### 47. Given two arrays, X and Y, construct the Cauchy matrix C (Cij =1/(xi - yj)) (★★☆)
|
||||||
|
|
||||||
#### 48. Print the minimum and maximum representable value for each numpy scalar type (★★☆)
|
#### 48. Print the minimum and maximum representable value for each numpy scalar type (★★☆)
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ np.nan in set([np.nan])
|
|||||||
`hint: np.diag`
|
`hint: np.diag`
|
||||||
#### 19. Create a 8x8 matrix and fill it with a checkerboard pattern (★☆☆)
|
#### 19. Create a 8x8 matrix and fill it with a checkerboard pattern (★☆☆)
|
||||||
`hint: array[::2]`
|
`hint: array[::2]`
|
||||||
#### 20. Consider a (6,7,8) shape array, what is the index (x,y,z) of the 100th element?
|
#### 20. Consider a (6,7,8) shape array, what is the index (x,y,z) of the 100th element? (★☆☆)
|
||||||
`hint: np.unravel_index`
|
`hint: np.unravel_index`
|
||||||
#### 21. Create a checkerboard 8x8 matrix using the tile function (★☆☆)
|
#### 21. Create a checkerboard 8x8 matrix using the tile function (★☆☆)
|
||||||
`hint: np.tile`
|
`hint: np.tile`
|
||||||
@ -89,7 +89,7 @@ Z/1/1
|
|||||||
Z<Z>Z
|
Z<Z>Z
|
||||||
```
|
```
|
||||||
`No hints provided...`
|
`No hints provided...`
|
||||||
#### 28. What are the result of the following expressions?
|
#### 28. What are the result of the following expressions? (★☆☆)
|
||||||
```python
|
```python
|
||||||
np.array(0) / np.array(0)
|
np.array(0) / np.array(0)
|
||||||
np.array(0) // np.array(0)
|
np.array(0) // np.array(0)
|
||||||
@ -135,7 +135,7 @@ np.sqrt(-1) == np.emath.sqrt(-1)
|
|||||||
`hint: argmax`
|
`hint: argmax`
|
||||||
#### 46. Create a structured array with `x` and `y` coordinates covering the [0,1]x[0,1] area (★★☆)
|
#### 46. Create a structured array with `x` and `y` coordinates covering the [0,1]x[0,1] area (★★☆)
|
||||||
`hint: np.meshgrid`
|
`hint: np.meshgrid`
|
||||||
#### 47. Given two arrays, X and Y, construct the Cauchy matrix C (Cij =1/(xi - yj))
|
#### 47. Given two arrays, X and Y, construct the Cauchy matrix C (Cij =1/(xi - yj)) (★★☆)
|
||||||
`hint: np.subtract.outer`
|
`hint: np.subtract.outer`
|
||||||
#### 48. Print the minimum and maximum representable value for each numpy scalar type (★★☆)
|
#### 48. Print the minimum and maximum representable value for each numpy scalar type (★★☆)
|
||||||
`hint: np.iinfo, np.finfo, eps`
|
`hint: np.iinfo, np.finfo, eps`
|
||||||
|
@ -168,7 +168,7 @@ Z[1::2,::2] = 1
|
|||||||
Z[::2,1::2] = 1
|
Z[::2,1::2] = 1
|
||||||
print(Z)
|
print(Z)
|
||||||
```
|
```
|
||||||
#### 20. Consider a (6,7,8) shape array, what is the index (x,y,z) of the 100th element?
|
#### 20. Consider a (6,7,8) shape array, what is the index (x,y,z) of the 100th element? (★☆☆)
|
||||||
`hint: np.unravel_index`
|
`hint: np.unravel_index`
|
||||||
|
|
||||||
```python
|
```python
|
||||||
@ -255,7 +255,7 @@ Z <- Z
|
|||||||
Z/1/1
|
Z/1/1
|
||||||
Z<Z>Z
|
Z<Z>Z
|
||||||
```
|
```
|
||||||
#### 28. What are the result of the following expressions?
|
#### 28. What are the result of the following expressions? (★☆☆)
|
||||||
```python
|
```python
|
||||||
np.array(0) / np.array(0)
|
np.array(0) / np.array(0)
|
||||||
np.array(0) // np.array(0)
|
np.array(0) // np.array(0)
|
||||||
@ -447,7 +447,7 @@ Z['x'], Z['y'] = np.meshgrid(np.linspace(0,1,5),
|
|||||||
np.linspace(0,1,5))
|
np.linspace(0,1,5))
|
||||||
print(Z)
|
print(Z)
|
||||||
```
|
```
|
||||||
#### 47. Given two arrays, X and Y, construct the Cauchy matrix C (Cij =1/(xi - yj))
|
#### 47. Given two arrays, X and Y, construct the Cauchy matrix C (Cij =1/(xi - yj)) (★★☆)
|
||||||
`hint: np.subtract.outer`
|
`hint: np.subtract.outer`
|
||||||
|
|
||||||
```python
|
```python
|
||||||
@ -827,7 +827,7 @@ from numpy.lib import stride_tricks
|
|||||||
|
|
||||||
def rolling(a, window):
|
def rolling(a, window):
|
||||||
shape = (a.size - window + 1, window)
|
shape = (a.size - window + 1, window)
|
||||||
strides = (a.itemsize, a.itemsize)
|
strides = (a.strides[0], a.strides[0])
|
||||||
return stride_tricks.as_strided(a, shape=shape, strides=strides)
|
return stride_tricks.as_strided(a, shape=shape, strides=strides)
|
||||||
Z = rolling(np.arange(10), 3)
|
Z = rolling(np.arange(10), 3)
|
||||||
print(Z)
|
print(Z)
|
||||||
|
@ -168,7 +168,7 @@ Z[1::2,::2] = 1
|
|||||||
Z[::2,1::2] = 1
|
Z[::2,1::2] = 1
|
||||||
print(Z)
|
print(Z)
|
||||||
```
|
```
|
||||||
#### 20. Consider a (6,7,8) shape array, what is the index (x,y,z) of the 100th element?
|
#### 20. Consider a (6,7,8) shape array, what is the index (x,y,z) of the 100th element? (★☆☆)
|
||||||
|
|
||||||
|
|
||||||
```python
|
```python
|
||||||
@ -255,7 +255,7 @@ Z <- Z
|
|||||||
Z/1/1
|
Z/1/1
|
||||||
Z<Z>Z
|
Z<Z>Z
|
||||||
```
|
```
|
||||||
#### 28. What are the result of the following expressions?
|
#### 28. What are the result of the following expressions? (★☆☆)
|
||||||
```python
|
```python
|
||||||
np.array(0) / np.array(0)
|
np.array(0) / np.array(0)
|
||||||
np.array(0) // np.array(0)
|
np.array(0) // np.array(0)
|
||||||
@ -447,7 +447,7 @@ Z['x'], Z['y'] = np.meshgrid(np.linspace(0,1,5),
|
|||||||
np.linspace(0,1,5))
|
np.linspace(0,1,5))
|
||||||
print(Z)
|
print(Z)
|
||||||
```
|
```
|
||||||
#### 47. Given two arrays, X and Y, construct the Cauchy matrix C (Cij =1/(xi - yj))
|
#### 47. Given two arrays, X and Y, construct the Cauchy matrix C (Cij =1/(xi - yj)) (★★☆)
|
||||||
|
|
||||||
|
|
||||||
```python
|
```python
|
||||||
@ -827,7 +827,7 @@ from numpy.lib import stride_tricks
|
|||||||
|
|
||||||
def rolling(a, window):
|
def rolling(a, window):
|
||||||
shape = (a.size - window + 1, window)
|
shape = (a.size - window + 1, window)
|
||||||
strides = (a.itemsize, a.itemsize)
|
strides = (a.strides[0], a.strides[0])
|
||||||
return stride_tricks.as_strided(a, shape=shape, strides=strides)
|
return stride_tricks.as_strided(a, shape=shape, strides=strides)
|
||||||
Z = rolling(np.arange(10), 3)
|
Z = rolling(np.arange(10), 3)
|
||||||
print(Z)
|
print(Z)
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"cells": [
|
"cells": [
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"id": "9187d1fe",
|
"id": "bbe15f43",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
"# 100 numpy exercises\n",
|
"# 100 numpy exercises\n",
|
||||||
@ -18,7 +18,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"id": "7b3fced0",
|
"id": "ed56e5f0",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
"File automatically generated. See the documentation to update questions/answers/hints programmatically."
|
"File automatically generated. See the documentation to update questions/answers/hints programmatically."
|
||||||
@ -26,7 +26,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"id": "77575766",
|
"id": "14866554",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
"Run the `initialize.py` module, then call a random question with `pick()` an hint towards its solution with\n",
|
"Run the `initialize.py` module, then call a random question with `pick()` an hint towards its solution with\n",
|
||||||
@ -36,7 +36,7 @@
|
|||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"id": "bcf0dd93",
|
"id": "af8b6f2a",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@ -46,7 +46,7 @@
|
|||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"id": "f401c090",
|
"id": "f13ecfd7",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
|
@ -212,7 +212,7 @@ Z[::2,1::2] = 1
|
|||||||
print(Z)
|
print(Z)
|
||||||
|
|
||||||
< q20
|
< q20
|
||||||
Consider a (6,7,8) shape array, what is the index (x,y,z) of the 100th element?
|
Consider a (6,7,8) shape array, what is the index (x,y,z) of the 100th element? (★☆☆)
|
||||||
|
|
||||||
< h20
|
< h20
|
||||||
hint: np.unravel_index
|
hint: np.unravel_index
|
||||||
@ -323,7 +323,7 @@ Z/1/1
|
|||||||
Z<Z>Z
|
Z<Z>Z
|
||||||
|
|
||||||
< q28
|
< q28
|
||||||
What are the result of the following expressions?
|
What are the result of the following expressions? (★☆☆)
|
||||||
```python
|
```python
|
||||||
np.array(0) / np.array(0)
|
np.array(0) / np.array(0)
|
||||||
np.array(0) // np.array(0)
|
np.array(0) // np.array(0)
|
||||||
@ -572,7 +572,7 @@ Z['x'], Z['y'] = np.meshgrid(np.linspace(0,1,5),
|
|||||||
print(Z)
|
print(Z)
|
||||||
|
|
||||||
< q47
|
< q47
|
||||||
Given two arrays, X and Y, construct the Cauchy matrix C (Cij =1/(xi - yj))
|
Given two arrays, X and Y, construct the Cauchy matrix C (Cij =1/(xi - yj)) (★★☆)
|
||||||
|
|
||||||
< h47
|
< h47
|
||||||
hint: np.subtract.outer
|
hint: np.subtract.outer
|
||||||
|
Loading…
Reference in New Issue
Block a user