Add code to exercises where it is needed

This commit is contained in:
Mateusz Flieger 2016-10-18 19:41:12 +02:00
parent 9933e1b6b6
commit 614fa8f2c8

View File

@ -275,6 +275,19 @@
"#### 17. What is the result of the following expression? (★☆☆)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"```python\n",
"0 * np.nan\n",
"np.nan == np.nan\n",
"np.inf > np.nan\n",
"np.nan - np.nan\n",
"0.3 == 3 * 0.1\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": null,
@ -419,6 +432,19 @@
"#### 26. What is the output of the following script? (★☆☆)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"```python\n",
"# Author: Jake VanderPlas\n",
"\n",
"print(sum(range(5),-1))\n",
"from numpy import *\n",
"print(sum(range(5),-1))\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": null,
@ -435,6 +461,20 @@
"#### 27. Consider an integer vector Z, which of these expressions are legal? (★☆☆)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"```python\n",
"Z**Z\n",
"2 << Z >> 2\n",
"Z <- Z\n",
"1j*Z\n",
"Z/1/1\n",
"Z<Z>Z\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": null,
@ -451,6 +491,17 @@
"#### 28. What are the result of the following expressions?"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"```python\n",
"np.array(0) / np.array(0)\n",
"np.array(0) // np.array(0)\n",
"np.array([np.nan]).astype(int).astype(float)\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": null,
@ -515,6 +566,15 @@
"#### 32. Is the following expressions true? (★☆☆)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"```python\n",
"np.sqrt(-1) == np.emath.sqrt(-1)\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": null,
@ -867,6 +927,17 @@
"#### 54. How to read the following file? (★★☆)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"```\n",
"1, 2, 3, 4, 5\n",
"6, , , 7, 8\n",
" , , 9,10,11\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": null,