Skip to content

Commit cb1bb28

Browse files
committed
minor fix before ensai session
1 parent eeae807 commit cb1bb28

File tree

6 files changed

+319
-910
lines changed

6 files changed

+319
-910
lines changed

notebooks/01-Introduction.ipynb

Lines changed: 167 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,6 @@
3232
"- Python 2 is retired use only Python 3\n"
3333
]
3434
},
35-
{
36-
"cell_type": "markdown",
37-
"metadata": {},
38-
"source": [
39-
"## Python distributions\n",
40-
"\n",
41-
" Python packages are available with all linux distributions but you can get standalone bundles:\n",
42-
"\n",
43-
"- [Anaconda](https://www.continuum.io/downloads)\n",
44-
"- [Enthought Tools Suite](https://docs.enthought.com/ets/)\n",
45-
"- [Astropy](http://www.astropy.org)\n",
46-
"- [SAGEMATH](http://sagemath.org/)\n",
47-
"- [Pyzo](http://www.pyzo.org)\n"
48-
]
49-
},
5035
{
5136
"cell_type": "markdown",
5237
"metadata": {},
@@ -143,27 +128,43 @@
143128
},
144129
{
145130
"cell_type": "code",
146-
"execution_count": null,
147-
"metadata": {},
148-
"outputs": [],
131+
"execution_count": 1,
132+
"metadata": {},
133+
"outputs": [
134+
{
135+
"name": "stdout",
136+
"output_type": "stream",
137+
"text": [
138+
"<class 'str'> Hello World!\n"
139+
]
140+
}
141+
],
149142
"source": [
150143
"s = \"Hello World!\"\n",
151144
"print(type(s),s)"
152145
]
153146
},
154147
{
155148
"cell_type": "code",
156-
"execution_count": null,
157-
"metadata": {},
158-
"outputs": [],
149+
"execution_count": 2,
150+
"metadata": {},
151+
"outputs": [
152+
{
153+
"name": "stdout",
154+
"output_type": "stream",
155+
"text": [
156+
"<class 'int'> 6625\n"
157+
]
158+
}
159+
],
159160
"source": [
160161
"a = 6625\n",
161162
"print(type(a),a)"
162163
]
163164
},
164165
{
165166
"cell_type": "code",
166-
"execution_count": null,
167+
"execution_count": 3,
167168
"metadata": {},
168169
"outputs": [],
169170
"source": [
@@ -179,9 +180,17 @@
179180
},
180181
{
181182
"cell_type": "code",
182-
"execution_count": null,
183-
"metadata": {},
184-
"outputs": [],
183+
"execution_count": 4,
184+
"metadata": {},
185+
"outputs": [
186+
{
187+
"name": "stdout",
188+
"output_type": "stream",
189+
"text": [
190+
"Writing hello.py\n"
191+
]
192+
}
193+
],
185194
"source": [
186195
"%%file hello.py\n",
187196
"\n",
@@ -221,9 +230,18 @@
221230
},
222231
{
223232
"cell_type": "code",
224-
"execution_count": null,
225-
"metadata": {},
226-
"outputs": [],
233+
"execution_count": 5,
234+
"metadata": {},
235+
"outputs": [
236+
{
237+
"name": "stdout",
238+
"output_type": "stream",
239+
"text": [
240+
"<class 'str'> Hello World!\n",
241+
"<class 'int'> 6625\n"
242+
]
243+
}
244+
],
227245
"source": [
228246
"%run hello.py"
229247
]
@@ -239,9 +257,22 @@
239257
},
240258
{
241259
"cell_type": "code",
242-
"execution_count": null,
243-
"metadata": {},
244-
"outputs": [],
260+
"execution_count": 6,
261+
"metadata": {},
262+
"outputs": [
263+
{
264+
"name": "stdout",
265+
"output_type": "stream",
266+
"text": [
267+
"<class 'int'>\n",
268+
"<class 'float'>\n",
269+
"<class 'bool'>\n",
270+
"<class 'NoneType'>\n",
271+
"<class 'complex'>\n",
272+
"<class 'type'>\n"
273+
]
274+
}
275+
],
245276
"source": [
246277
"s = int(2010); print(type(s))\n",
247278
"s = 3.14; print(type(s))\n",
@@ -260,9 +291,17 @@
260291
},
261292
{
262293
"cell_type": "code",
263-
"execution_count": null,
264-
"metadata": {},
265-
"outputs": [],
294+
"execution_count": 7,
295+
"metadata": {},
296+
"outputs": [
297+
{
298+
"name": "stdout",
299+
"output_type": "stream",
300+
"text": [
301+
"47 True\n"
302+
]
303+
}
304+
],
266305
"source": [
267306
"x = 45 # This is a comment!\n",
268307
"x += 2 # equivalent to x = x + 2\n",
@@ -271,38 +310,71 @@
271310
},
272311
{
273312
"cell_type": "code",
274-
"execution_count": null,
275-
"metadata": {},
276-
"outputs": [],
313+
"execution_count": 8,
314+
"metadata": {},
315+
"outputs": [
316+
{
317+
"name": "stdout",
318+
"output_type": "stream",
319+
"text": [
320+
"x+y= 49.5 <class 'float'>\n"
321+
]
322+
}
323+
],
277324
"source": [
278325
"y = 2.5\n",
279326
"print(\"x+y=\",x+y, type(x+y)) # Add float to integer, result will be a float"
280327
]
281328
},
282329
{
283330
"cell_type": "code",
284-
"execution_count": null,
285-
"metadata": {},
286-
"outputs": [],
331+
"execution_count": 9,
332+
"metadata": {},
333+
"outputs": [
334+
{
335+
"name": "stdout",
336+
"output_type": "stream",
337+
"text": [
338+
"188.0\n",
339+
"156\n"
340+
]
341+
}
342+
],
287343
"source": [
288344
"print(x*10/y) # true division returns a float\n",
289345
"print(x*10//3) # floor division discards the fractional part"
290346
]
291347
},
292348
{
293349
"cell_type": "code",
294-
"execution_count": null,
295-
"metadata": {},
296-
"outputs": [],
350+
"execution_count": 10,
351+
"metadata": {},
352+
"outputs": [
353+
{
354+
"name": "stdout",
355+
"output_type": "stream",
356+
"text": [
357+
"7\n"
358+
]
359+
}
360+
],
297361
"source": [
298362
"print( x % 8) # the % operator returns the remainder of the division"
299363
]
300364
},
301365
{
302366
"cell_type": "code",
303-
"execution_count": null,
304-
"metadata": {},
305-
"outputs": [],
367+
"execution_count": 11,
368+
"metadata": {},
369+
"outputs": [
370+
{
371+
"name": "stdout",
372+
"output_type": "stream",
373+
"text": [
374+
" x = 00047 \n"
375+
]
376+
}
377+
],
306378
"source": [
307379
"print( f\" x = {x:05d} \") # You can use C format rules to improve print output"
308380
]
@@ -320,39 +392,74 @@
320392
},
321393
{
322394
"cell_type": "code",
323-
"execution_count": null,
324-
"metadata": {},
325-
"outputs": [],
395+
"execution_count": 12,
396+
"metadata": {},
397+
"outputs": [
398+
{
399+
"name": "stdout",
400+
"output_type": "stream",
401+
"text": [
402+
"1 1 1\n"
403+
]
404+
}
405+
],
326406
"source": [
327407
"a = b = c = 1\n",
328408
"print(a, b, c) "
329409
]
330410
},
331411
{
332412
"cell_type": "code",
333-
"execution_count": null,
334-
"metadata": {},
335-
"outputs": [],
413+
"execution_count": 13,
414+
"metadata": {},
415+
"outputs": [
416+
{
417+
"name": "stdout",
418+
"output_type": "stream",
419+
"text": [
420+
"1 2 3\n"
421+
]
422+
}
423+
],
336424
"source": [
337425
"a, b, c = 1, 2, 3\n",
338426
"print (a, b, c)"
339427
]
340428
},
341429
{
342430
"cell_type": "code",
343-
"execution_count": null,
344-
"metadata": {},
345-
"outputs": [],
431+
"execution_count": 14,
432+
"metadata": {},
433+
"outputs": [
434+
{
435+
"name": "stdout",
436+
"output_type": "stream",
437+
"text": [
438+
"3 2 1\n"
439+
]
440+
}
441+
],
346442
"source": [
347443
"a, c = c, a # Nice way to permute values\n",
348444
"print (a, b, c) "
349445
]
350446
},
351447
{
352448
"cell_type": "code",
353-
"execution_count": null,
354-
"metadata": {},
355-
"outputs": [],
449+
"execution_count": 15,
450+
"metadata": {},
451+
"outputs": [
452+
{
453+
"data": {
454+
"text/plain": [
455+
"(False, True)"
456+
]
457+
},
458+
"execution_count": 15,
459+
"metadata": {},
460+
"output_type": "execute_result"
461+
}
462+
],
356463
"source": [
357464
"a < b < c, a > b > c"
358465
]
@@ -377,7 +484,7 @@
377484
],
378485
"metadata": {
379486
"kernelspec": {
380-
"display_name": "Python 3",
487+
"display_name": "Python 3 (ipykernel)",
381488
"language": "python",
382489
"name": "python3"
383490
},
@@ -391,7 +498,7 @@
391498
"name": "python",
392499
"nbconvert_exporter": "python",
393500
"pygments_lexer": "ipython3",
394-
"version": "3.8.5"
501+
"version": "3.10.14"
395502
}
396503
},
397504
"nbformat": 4,

0 commit comments

Comments
 (0)