Skip to content

Commit 83b6e64

Browse files
committed
lecture 02 python data structures
1 parent 2b80b65 commit 83b6e64

11 files changed

+3250
-2
lines changed
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "frank-basement",
6+
"metadata": {},
7+
"source": [
8+
"# Pitfalls when working with Jupyter notebooks\n",
9+
"You can execute the same cell in Jupyter notebooks multiple times. This may lead to notebooks which make no sense to the reader."
10+
]
11+
},
12+
{
13+
"cell_type": "code",
14+
"execution_count": 3,
15+
"id": "metallic-classification",
16+
"metadata": {},
17+
"outputs": [],
18+
"source": [
19+
"a = 5\n",
20+
"b = 5"
21+
]
22+
},
23+
{
24+
"cell_type": "code",
25+
"execution_count": 6,
26+
"id": "wired-crowd",
27+
"metadata": {},
28+
"outputs": [],
29+
"source": [
30+
"a = a + 1"
31+
]
32+
},
33+
{
34+
"cell_type": "code",
35+
"execution_count": 7,
36+
"id": "shaped-capital",
37+
"metadata": {},
38+
"outputs": [
39+
{
40+
"data": {
41+
"text/plain": [
42+
"13"
43+
]
44+
},
45+
"execution_count": 7,
46+
"metadata": {},
47+
"output_type": "execute_result"
48+
}
49+
],
50+
"source": [
51+
"a + b"
52+
]
53+
},
54+
{
55+
"cell_type": "markdown",
56+
"id": "olympic-vienna",
57+
"metadata": {},
58+
"source": [
59+
"You can execute them in the wrong order which leads to the same effect."
60+
]
61+
},
62+
{
63+
"cell_type": "code",
64+
"execution_count": 10,
65+
"id": "backed-shaft",
66+
"metadata": {},
67+
"outputs": [],
68+
"source": [
69+
"d = 5"
70+
]
71+
},
72+
{
73+
"cell_type": "code",
74+
"execution_count": 9,
75+
"id": "military-bedroom",
76+
"metadata": {},
77+
"outputs": [],
78+
"source": [
79+
"d = 10"
80+
]
81+
},
82+
{
83+
"cell_type": "code",
84+
"execution_count": 11,
85+
"id": "radical-shakespeare",
86+
"metadata": {},
87+
"outputs": [
88+
{
89+
"data": {
90+
"text/plain": [
91+
"5"
92+
]
93+
},
94+
"execution_count": 11,
95+
"metadata": {},
96+
"output_type": "execute_result"
97+
}
98+
],
99+
"source": [
100+
"d"
101+
]
102+
},
103+
{
104+
"cell_type": "markdown",
105+
"id": "persistent-porcelain",
106+
"metadata": {},
107+
"source": [
108+
"You can see that cells were executed in wrong order, repeatedly or not subsequently, by reading the number `In [?]` on the left.\n",
109+
"\n",
110+
"![ ](cell_execution_number.png)\n",
111+
"\n",
112+
"Tip: When your notebook is ready, click on menu `Kernel > Restart & Run all` to make sure all cells in the notebook are executed in the right order."
113+
]
114+
},
115+
{
116+
"cell_type": "code",
117+
"execution_count": null,
118+
"id": "conservative-cyprus",
119+
"metadata": {},
120+
"outputs": [],
121+
"source": []
122+
}
123+
],
124+
"metadata": {
125+
"kernelspec": {
126+
"display_name": "Python 3 (ipykernel)",
127+
"language": "python",
128+
"name": "python3"
129+
},
130+
"language_info": {
131+
"codemirror_mode": {
132+
"name": "ipython",
133+
"version": 3
134+
},
135+
"file_extension": ".py",
136+
"mimetype": "text/x-python",
137+
"name": "python",
138+
"nbconvert_exporter": "python",
139+
"pygments_lexer": "ipython3",
140+
"version": "3.9.10"
141+
}
142+
},
143+
"nbformat": 4,
144+
"nbformat_minor": 5
145+
}

0 commit comments

Comments
 (0)