Skip to content

Commit 5c33123

Browse files
committed
More additions
1 parent d013dd7 commit 5c33123

1 file changed

Lines changed: 18 additions & 50 deletions

File tree

‎01_jupyter_howto.ipynb‎

Lines changed: 18 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,9 @@
2020
},
2121
{
2222
"cell_type": "code",
23-
"execution_count": 3,
23+
"execution_count": null,
2424
"metadata": {},
25-
"outputs": [
26-
{
27-
"name": "stdout",
28-
"output_type": "stream",
29-
"text": [
30-
"Hello World\n"
31-
]
32-
}
33-
],
25+
"outputs": [],
3426
"source": [
3527
"print(\"Hello World\")"
3628
]
@@ -46,27 +38,9 @@
4638
},
4739
{
4840
"cell_type": "code",
49-
"execution_count": 5,
41+
"execution_count": null,
5042
"metadata": {},
51-
"outputs": [
52-
{
53-
"name": "stdout",
54-
"output_type": "stream",
55-
"text": [
56-
"10...\n",
57-
"9...\n",
58-
"8...\n",
59-
"7...\n",
60-
"6...\n",
61-
"5...\n",
62-
"4...\n",
63-
"3...\n",
64-
"2...\n",
65-
"1...\n",
66-
"Lift off!\n"
67-
]
68-
}
69-
],
43+
"outputs": [],
7044
"source": [
7145
"def countDown(start):\n",
7246
" for i in range(start, 0, -1):\n",
@@ -85,7 +59,7 @@
8559
},
8660
{
8761
"cell_type": "code",
88-
"execution_count": 10,
62+
"execution_count": null,
8963
"metadata": {},
9064
"outputs": [],
9165
"source": [
@@ -94,24 +68,9 @@
9468
},
9569
{
9670
"cell_type": "code",
97-
"execution_count": 9,
71+
"execution_count": null,
9872
"metadata": {},
99-
"outputs": [
100-
{
101-
"name": "stdout",
102-
"output_type": "stream",
103-
"text": [
104-
"7...\n",
105-
"6...\n",
106-
"5...\n",
107-
"4...\n",
108-
"3...\n",
109-
"2...\n",
110-
"1...\n",
111-
"Lift off!\n"
112-
]
113-
}
114-
],
73+
"outputs": [],
11574
"source": [
11675
"countDown(x)"
11776
]
@@ -122,8 +81,17 @@
12281
"source": [
12382
"You can go back up and edit the value of `x`. For example, set `x` to 7 and press SHIFT+Return. This has changed `x`. However, it doesn't re-run any code that depends on `x`. That is for you to do. You need to click on the next cell `countDown(x)` and press SHIFT+Return again. You should then see that the code is run and updated.\n",
12483
"\n",
125-
"Because you can change any cell at any time, a notebook can get into a confused state. If we change `x` again to `21`, then the cell `countDown(x)`, is now out of date, as it depends on the old value of `x`. So, how can we know what state each cell is in?\n",
126-
"\n"
84+
"Because you can change any cell at any time, a notebook can get into a confused state. If we change `x` again to `21`, then the cell `countDown(x)`, is now out of date, as it depends on the old value of `x`. So, how can we know what state each cell is in? The state is based on the order in which cells are executed. This is shown by the little number next to each cell, e.g. see below.\n",
85+
"\n",
86+
"![Image showing Jupyter state](images/jupyter_state.jpeg)\n",
87+
"\n",
88+
"The number \"10\" shows that the line `x = 21` was the 10th cell executed by Python, while the line `countDown(x)` was the 9th cell executed. As `countDown(x)` was executed before `x = 21`, it was not affected by `x = 21`. If you want it to be affected, you need to execute that cell again (so it is now the 11th cell executed), e.g.\n",
89+
"\n",
90+
"![Image showing updated Jupyer state](images/jupyter_state2.jpeg)\n",
91+
"\n",
92+
"If you find yourself getting confused, then click \"Kernel | Restart & Clear Output\" from the menu above to clear all outputs, clear the state, and reset back to a clean notebook.\n",
93+
"\n",
94+
"![Image showing clear and restart](images/jupyter_restart.jpeg)"
12795
]
12896
},
12997
{

0 commit comments

Comments
 (0)