|
20 | 20 | }, |
21 | 21 | { |
22 | 22 | "cell_type": "code", |
23 | | - "execution_count": 3, |
| 23 | + "execution_count": null, |
24 | 24 | "metadata": {}, |
25 | | - "outputs": [ |
26 | | - { |
27 | | - "name": "stdout", |
28 | | - "output_type": "stream", |
29 | | - "text": [ |
30 | | - "Hello World\n" |
31 | | - ] |
32 | | - } |
33 | | - ], |
| 25 | + "outputs": [], |
34 | 26 | "source": [ |
35 | 27 | "print(\"Hello World\")" |
36 | 28 | ] |
|
46 | 38 | }, |
47 | 39 | { |
48 | 40 | "cell_type": "code", |
49 | | - "execution_count": 5, |
| 41 | + "execution_count": null, |
50 | 42 | "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": [], |
70 | 44 | "source": [ |
71 | 45 | "def countDown(start):\n", |
72 | 46 | " for i in range(start, 0, -1):\n", |
|
85 | 59 | }, |
86 | 60 | { |
87 | 61 | "cell_type": "code", |
88 | | - "execution_count": 10, |
| 62 | + "execution_count": null, |
89 | 63 | "metadata": {}, |
90 | 64 | "outputs": [], |
91 | 65 | "source": [ |
|
94 | 68 | }, |
95 | 69 | { |
96 | 70 | "cell_type": "code", |
97 | | - "execution_count": 9, |
| 71 | + "execution_count": null, |
98 | 72 | "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": [], |
115 | 74 | "source": [ |
116 | 75 | "countDown(x)" |
117 | 76 | ] |
|
122 | 81 | "source": [ |
123 | 82 | "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", |
124 | 83 | "\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 | + "\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 | + "\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 | + "" |
127 | 95 | ] |
128 | 96 | }, |
129 | 97 | { |
|
0 commit comments