Skip to content

Commit e4f0e63

Browse files
committed
Materials for first day
1 parent c60ab55 commit e4f0e63

10 files changed

+49
-210
lines changed
Lines changed: 22 additions & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
},
187187
{
188188
"cell_type": "code",
189-
"execution_count": 5,
189+
"execution_count": null,
190190
"metadata": {},
191191
"outputs": [],
192192
"source": [
@@ -195,17 +195,9 @@
195195
},
196196
{
197197
"cell_type": "code",
198-
"execution_count": 8,
199-
"metadata": {},
200-
"outputs": [
201-
{
202-
"name": "stdout",
203-
"output_type": "stream",
204-
"text": [
205-
"11\n"
206-
]
207-
}
208-
],
198+
"execution_count": null,
199+
"metadata": {},
200+
"outputs": [],
209201
"source": [
210202
"print(a + 1)"
211203
]
@@ -219,20 +211,9 @@
219211
},
220212
{
221213
"cell_type": "code",
222-
"execution_count": 7,
223-
"metadata": {},
224-
"outputs": [
225-
{
226-
"data": {
227-
"text/plain": [
228-
"11"
229-
]
230-
},
231-
"execution_count": 7,
232-
"metadata": {},
233-
"output_type": "execute_result"
234-
}
235-
],
214+
"execution_count": null,
215+
"metadata": {},
216+
"outputs": [],
236217
"source": [
237218
"a + 1"
238219
]
@@ -270,21 +251,9 @@
270251
},
271252
{
272253
"cell_type": "code",
273-
"execution_count": 3,
274-
"metadata": {},
275-
"outputs": [
276-
{
277-
"ename": "KeyboardInterrupt",
278-
"evalue": "",
279-
"output_type": "error",
280-
"traceback": [
281-
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
282-
"\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)",
283-
"\u001b[0;32m<ipython-input-3-c20d360cf4b6>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mtime\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mtime\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msleep\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m10\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
284-
"\u001b[0;31mKeyboardInterrupt\u001b[0m: "
285-
]
286-
}
287-
],
254+
"execution_count": null,
255+
"metadata": {},
256+
"outputs": [],
288257
"source": [
289258
"import time\n",
290259
"time.sleep(10)"
@@ -364,34 +333,18 @@
364333
},
365334
{
366335
"cell_type": "code",
367-
"execution_count": 1,
368-
"metadata": {},
369-
"outputs": [
370-
{
371-
"name": "stdout",
372-
"output_type": "stream",
373-
"text": [
374-
"hi, stdout\n"
375-
]
376-
}
377-
],
336+
"execution_count": null,
337+
"metadata": {},
338+
"outputs": [],
378339
"source": [
379340
"print(\"hi, stdout\")"
380341
]
381342
},
382343
{
383344
"cell_type": "code",
384-
"execution_count": 2,
385-
"metadata": {},
386-
"outputs": [
387-
{
388-
"name": "stderr",
389-
"output_type": "stream",
390-
"text": [
391-
"hi, stderr\n"
392-
]
393-
}
394-
],
345+
"execution_count": null,
346+
"metadata": {},
347+
"outputs": [],
395348
"source": [
396349
"from __future__ import print_function\n",
397350
"print('hi, stderr', file=sys.stderr)"
@@ -413,24 +366,9 @@
413366
},
414367
{
415368
"cell_type": "code",
416-
"execution_count": 4,
417-
"metadata": {},
418-
"outputs": [
419-
{
420-
"name": "stdout",
421-
"output_type": "stream",
422-
"text": [
423-
"0\n",
424-
"1\n",
425-
"2\n",
426-
"3\n",
427-
"4\n",
428-
"5\n",
429-
"6\n",
430-
"7\n"
431-
]
432-
}
433-
],
369+
"execution_count": null,
370+
"metadata": {},
371+
"outputs": [],
434372
"source": [
435373
"import time, sys\n",
436374
"for i in range(8):\n",
@@ -454,71 +392,9 @@
454392
},
455393
{
456394
"cell_type": "code",
457-
"execution_count": 5,
458-
"metadata": {
459-
"collapsed": true,
460-
"jupyter": {
461-
"outputs_hidden": true
462-
}
463-
},
464-
"outputs": [
465-
{
466-
"name": "stdout",
467-
"output_type": "stream",
468-
"text": [
469-
"0\n",
470-
"1\n",
471-
"2\n",
472-
"3\n",
473-
"4\n",
474-
"5\n",
475-
"6\n",
476-
"7\n",
477-
"8\n",
478-
"9\n",
479-
"10\n",
480-
"11\n",
481-
"12\n",
482-
"13\n",
483-
"14\n",
484-
"15\n",
485-
"16\n",
486-
"17\n",
487-
"18\n",
488-
"19\n",
489-
"20\n",
490-
"21\n",
491-
"22\n",
492-
"23\n",
493-
"24\n",
494-
"25\n",
495-
"26\n",
496-
"27\n",
497-
"28\n",
498-
"29\n",
499-
"30\n",
500-
"31\n",
501-
"32\n",
502-
"33\n",
503-
"34\n",
504-
"35\n",
505-
"36\n",
506-
"37\n",
507-
"38\n",
508-
"39\n",
509-
"40\n",
510-
"41\n",
511-
"42\n",
512-
"43\n",
513-
"44\n",
514-
"45\n",
515-
"46\n",
516-
"47\n",
517-
"48\n",
518-
"49\n"
519-
]
520-
}
521-
],
395+
"execution_count": null,
396+
"metadata": {},
397+
"outputs": [],
522398
"source": [
523399
"for i in range(50):\n",
524400
" print(i)"
Lines changed: 24 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@
229229
"metadata": {},
230230
"outputs": [],
231231
"source": [
232-
"_10 == Out[10]"
232+
"_11 == Out[11]"
233233
]
234234
},
235235
{
@@ -309,8 +309,8 @@
309309
"metadata": {},
310310
"outputs": [],
311311
"source": [
312-
"files = !ls notebooks\n",
313-
"print(\"files in notebooks directory:\")\n",
312+
"files = !ls \n",
313+
"print(\"files this directory:\")\n",
314314
"print(files)"
315315
]
316316
},
@@ -663,7 +663,9 @@
663663
"cell_type": "markdown",
664664
"metadata": {},
665665
"source": [
666-
"## Running code in other languages with special `%%` magics"
666+
"## Basic debugging\n",
667+
"\n",
668+
"When running code interactively, it can be tricky to figure out how to debug... "
667669
]
668670
},
669671
{
@@ -672,9 +674,7 @@
672674
"metadata": {},
673675
"outputs": [],
674676
"source": [
675-
"%%perl\n",
676-
"@months = (\"July\", \"August\", \"September\");\n",
677-
"print $months[0];"
677+
"mod.g(0)"
678678
]
679679
},
680680
{
@@ -683,23 +683,14 @@
683683
"metadata": {},
684684
"outputs": [],
685685
"source": [
686-
"%%ruby\n",
687-
"name = \"world\"\n",
688-
"puts \"Hello #{name.capitalize}!\""
689-
]
690-
},
691-
{
692-
"cell_type": "markdown",
693-
"metadata": {},
694-
"source": [
695-
"## Raw Input in the notebook"
686+
"%debug"
696687
]
697688
},
698689
{
699690
"cell_type": "markdown",
700691
"metadata": {},
701692
"source": [
702-
"Since 1.0 the IPython notebook web application support `raw_input` which for example allow us to invoke the `%debug` magic in the notebook:"
693+
"Don't foget to exit your debugging session. Raw input can of course be use to ask for user input:"
703694
]
704695
},
705696
{
@@ -708,23 +699,26 @@
708699
"metadata": {},
709700
"outputs": [],
710701
"source": [
711-
"mod.g(0)"
702+
"enjoy = input('Are you enjoying this tutorial? ')\n",
703+
"print('enjoy is:', enjoy)"
712704
]
713705
},
714706
{
715-
"cell_type": "code",
716-
"execution_count": null,
707+
"cell_type": "markdown",
717708
"metadata": {},
718-
"outputs": [],
719709
"source": [
720-
"%debug"
710+
"## Running code in other languages with special `%%` magics"
721711
]
722712
},
723713
{
724-
"cell_type": "markdown",
714+
"cell_type": "code",
715+
"execution_count": null,
725716
"metadata": {},
717+
"outputs": [],
726718
"source": [
727-
"Don't foget to exit your debugging session. Raw input can of course be use to ask for user input:"
719+
"%%perl\n",
720+
"@months = (\"July\", \"August\", \"September\");\n",
721+
"print $months[0];"
728722
]
729723
},
730724
{
@@ -733,8 +727,9 @@
733727
"metadata": {},
734728
"outputs": [],
735729
"source": [
736-
"enjoy = input('Are you enjoying this tutorial? ')\n",
737-
"print('enjoy is:', enjoy)"
730+
"%%ruby\n",
731+
"name = \"world\"\n",
732+
"puts \"Hello #{name.capitalize}!\""
738733
]
739734
},
740735
{
@@ -779,40 +774,8 @@
779774
"x = np.linspace(0, 2*np.pi, 300)\n",
780775
"y = np.sin(x**2)\n",
781776
"plt.plot(x, y)\n",
782-
"plt.title(\"A little chirp\")\n",
783-
"fig = plt.gcf() # let's keep the figure object around for later..."
784-
]
785-
},
786-
{
787-
"cell_type": "markdown",
788-
"metadata": {},
789-
"source": [
790-
"# Ventures into widgets"
777+
"plt.title(\"A little chirp\")"
791778
]
792-
},
793-
{
794-
"cell_type": "code",
795-
"execution_count": null,
796-
"metadata": {},
797-
"outputs": [],
798-
"source": [
799-
"from ipywidgets import interact, interact_manual\n",
800-
"\n",
801-
"@interact(color=['C0','C1', 'C2'], f={'sine': np.sin, 'cos': np.cos})\n",
802-
"def myplot(f, λ=2.0, color='C0'):\n",
803-
" x = np.linspace(0, 2*np.pi, 300)\n",
804-
" y = f(λ*x**2)\n",
805-
" plt.plot(x, y, c=color)\n",
806-
" plt.title(f\"A little chirp (λ={λ})\")\n",
807-
" "
808-
]
809-
},
810-
{
811-
"cell_type": "code",
812-
"execution_count": null,
813-
"metadata": {},
814-
"outputs": [],
815-
"source": []
816779
}
817780
],
818781
"metadata": {
@@ -835,5 +798,5 @@
835798
}
836799
},
837800
"nbformat": 4,
838-
"nbformat_minor": 2
801+
"nbformat_minor": 4
839802
}
File renamed without changes.

0 commit comments

Comments
 (0)