diff --git a/images/program.svg b/images/program.svg index 8a7fd10e53ad476b6bdd6cfbd85ef6e99c2ff21e..0582d4d4154b6f98cead5cbe61823ce9b439ab38 100644 --- a/images/program.svg +++ b/images/program.svg @@ -10,11 +10,11 @@ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="269.34595mm" - height="115.88752mm" - viewBox="0 0 269.34595 115.88752" + height="142.34586mm" + viewBox="0 0 269.34595 142.34586" version="1.1" id="svg8" - inkscape:version="0.92.3 (unknown)" + inkscape:version="0.92.3 (2405546, 2018-03-11)" sodipodi:docname="program.svg"> <defs id="defs2" /> @@ -26,18 +26,18 @@ inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="0.98994949" - inkscape:cx="540.29667" - inkscape:cy="85.179993" + inkscape:cx="515.56275" + inkscape:cy="253.09843" inkscape:document-units="mm" inkscape:current-layer="layer1" showgrid="false" showguides="true" inkscape:guide-bbox="true" - inkscape:window-width="1920" - inkscape:window-height="1136" - inkscape:window-x="1280" + inkscape:window-width="1588" + inkscape:window-height="1382" + inkscape:window-x="972" inkscape:window-y="27" - inkscape:window-maximized="1" + inkscape:window-maximized="0" fit-margin-top="0" fit-margin-left="0" fit-margin-right="0" @@ -59,6 +59,13 @@ inkscape:groupmode="layer" id="layer1" transform="translate(-27.970237,-37.141367)"> + <path + style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#a9a9a9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1.99999988;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" + d="m 142,302 v 60 16 160 h 876 V 362 H 578 v -60 z" + transform="matrix(0.26458333,0,0,0.26458333,27.970237,37.141367)" + id="path949" + inkscape:connector-curvature="0" + sodipodi:nodetypes="ccccccccc" /> <path sodipodi:nodetypes="ccccc" inkscape:connector-curvature="0" @@ -137,11 +144,11 @@ sodipodi:nodetypes="ccccc" inkscape:connector-curvature="0" id="path1032" - d="m 181.95779,85.295539 h 57.15003 V 100.1122 h -57.15003 z" + d="m 181.95779,101.17054 h 57.15003 v 14.81667 h -57.15003 z" style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#a9a9a9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.52916664;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" /> <path style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#b0e0e6;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.52916664;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" - d="m 181.42862,84.766369 h 57.15003 v 14.816664 h -57.15003 z" + d="m 181.42862,100.64137 h 57.15003 v 14.81667 h -57.15003 z" id="path1034" inkscape:connector-curvature="0" sodipodi:nodetypes="ccccc" /> @@ -149,21 +156,21 @@ xml:space="preserve" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52777767px;line-height:125%;font-family:mono;-inkscape-font-specification:mono;text-align:center;letter-spacing:7.3342495px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" x="209.99072" - y="91.207748" + y="107.08274" id="text1040"><tspan sodipodi:role="line" x="210.12302" - y="91.207748" + y="107.08274" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:sans-serif;-inkscape-font-specification:sans-serif;text-align:center;letter-spacing:0.26458332px;text-anchor:middle;stroke-width:0.26458332px" id="tspan1038">Data mangling</tspan><tspan sodipodi:role="line" x="210.12302" - y="95.61747" + y="111.49246" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:sans-serif;-inkscape-font-specification:sans-serif;text-align:center;letter-spacing:0.26458332px;text-anchor:middle;stroke-width:0.26458332px" id="tspan1264">with pandas</tspan></text> <path style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#a9a9a9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.52916664;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" - d="m 240.16616,53.545535 h 57.15003 v 14.816667 h -57.15003 z" + d="m 240.16616,69.420536 h 57.15003 v 14.816667 h -57.15003 z" id="path1062" inkscape:connector-curvature="0" sodipodi:nodetypes="ccccc" /> @@ -171,21 +178,21 @@ sodipodi:nodetypes="ccccc" inkscape:connector-curvature="0" id="path1064" - d="m 239.63699,53.016368 h 57.15003 v 14.816667 h -57.15003 z" + d="m 239.63699,68.891369 h 57.15003 v 14.816667 h -57.15003 z" style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#b0e0e6;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.52916664;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" /> <text id="text1070" - y="59.457767" + y="75.332764" x="268.19046" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52777767px;line-height:125%;font-family:mono;-inkscape-font-specification:mono;text-align:center;letter-spacing:7.3342495px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" xml:space="preserve"><tspan style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:sans-serif;-inkscape-font-specification:sans-serif;text-align:center;letter-spacing:0.26458332px;text-anchor:middle;stroke-width:0.26458332px" - y="59.457767" + y="75.332764" x="268.32275" sodipodi:role="line" id="tspan1268">Data visualisation</tspan><tspan style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:sans-serif;-inkscape-font-specification:sans-serif;text-align:center;letter-spacing:0.26458332px;text-anchor:middle;stroke-width:0.26458332px" - y="63.867489" + y="79.742485" x="268.32275" sodipodi:role="line" id="tspan1272">with Matplotlib</tspan></text> @@ -283,7 +290,7 @@ id="tspan1128">12:00 - 13:00</tspan></text> <path style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#a9a9a9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.52916664;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" - d="m 28.499404,117.04555 h 35.983321 v 35.98334 H 28.499404 Z" + d="m 28.499404,132.92056 h 35.983321 v 46.56667 H 28.499404 Z" id="path1132" inkscape:connector-curvature="0" sodipodi:nodetypes="ccccc" /> @@ -291,19 +298,19 @@ sodipodi:nodetypes="ccccc" inkscape:connector-curvature="0" id="path1134" - d="m 27.970237,116.51638 h 35.983318 v 35.98334 H 27.970237 Z" + d="m 27.970237,132.39139 h 35.983318 v 46.56667 H 27.970237 Z" style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#f5f5f5;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.52916664;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" /> <text id="text1138" - y="135.79221" + y="156.95889" x="30.693922" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52777767px;line-height:125%;font-family:mono;-inkscape-font-specification:mono;text-align:start;letter-spacing:7.3342495px;word-spacing:0px;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" xml:space="preserve"><tspan id="tspan1136" style="text-align:start;letter-spacing:0.26458332px;text-anchor:start;stroke-width:0.26458332px" - y="135.79221" + y="156.95889" x="30.693922" - sodipodi:role="line">13:00 - 16:00</tspan></text> + sodipodi:role="line">14:00 - 17:00</tspan></text> <path sodipodi:nodetypes="ccccc" inkscape:connector-curvature="0" @@ -326,7 +333,7 @@ x="93.633072" y="93.093674" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:sans-serif;-inkscape-font-specification:sans-serif;text-align:center;letter-spacing:0.26458332px;text-anchor:middle;stroke-width:0.26458332px" - id="tspan1144">Functions</tspan></text> + id="tspan1144">Flow control</tspan></text> <path sodipodi:nodetypes="ccccc" inkscape:connector-curvature="0" @@ -385,7 +392,7 @@ sodipodi:role="line">and writing files</tspan></text> <path style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#a9a9a9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.52916664;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" - d="m 181.95779,53.545535 h 57.15003 v 14.816667 h -57.15003 z" + d="m 181.95779,69.420536 h 57.15003 v 14.816667 h -57.15003 z" id="path1168" inkscape:connector-curvature="0" sodipodi:nodetypes="ccccc" /> @@ -393,21 +400,21 @@ sodipodi:nodetypes="ccccc" inkscape:connector-curvature="0" id="path1170" - d="m 181.42862,53.016368 h 57.15003 v 14.816667 h -57.15003 z" + d="m 181.42862,68.891369 h 57.15003 v 14.816667 h -57.15003 z" style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#b0e0e6;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.52916664;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" /> <text id="text1176" - y="59.457767" + y="75.332764" x="210.06479" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52777767px;line-height:125%;font-family:mono;-inkscape-font-specification:mono;text-align:center;letter-spacing:7.3342495px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" xml:space="preserve"><tspan id="tspan1174" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:sans-serif;-inkscape-font-specification:sans-serif;text-align:center;letter-spacing:0.26458332px;text-anchor:middle;stroke-width:0.26458332px" - y="59.457767" + y="75.332764" x="210.19708" sodipodi:role="line">Object-oriented</tspan><tspan style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:sans-serif;-inkscape-font-specification:sans-serif;text-align:center;letter-spacing:0.26458332px;text-anchor:middle;stroke-width:0.26458332px" - y="63.867489" + y="79.742485" x="210.19708" sodipodi:role="line" id="tspan1218">programming</tspan></text> @@ -415,11 +422,11 @@ sodipodi:nodetypes="ccccc" inkscape:connector-curvature="0" id="path1178" - d="m 240.16616,69.420536 h 57.15003 v 14.816667 h -57.15003 z" + d="m 240.16616,85.295537 h 57.15003 V 100.1122 h -57.15003 z" style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#a9a9a9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.52916664;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" /> <path style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#b0e0e6;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.52916664;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" - d="m 239.63699,68.891369 h 57.15003 v 14.816667 h -57.15003 z" + d="m 239.63699,84.76637 h 57.15003 v 14.816667 h -57.15003 z" id="path1180" inkscape:connector-curvature="0" sodipodi:nodetypes="ccccc" /> @@ -427,27 +434,27 @@ xml:space="preserve" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52777767px;line-height:125%;font-family:mono;-inkscape-font-specification:mono;text-align:center;letter-spacing:7.3342495px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" x="268.19046" - y="75.332764" + y="91.207756" id="text1186"><tspan sodipodi:role="line" x="268.32275" - y="75.332764" + y="91.207756" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:sans-serif;-inkscape-font-specification:sans-serif;text-align:center;letter-spacing:0.26458332px;text-anchor:middle;stroke-width:0.26458332px" id="tspan1184">Data visualisation</tspan><tspan sodipodi:role="line" x="268.32275" - y="79.742485" + y="95.617477" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:sans-serif;-inkscape-font-specification:sans-serif;text-align:center;letter-spacing:0.26458332px;text-anchor:middle;stroke-width:0.26458332px" id="tspan1276">with Bokeh</tspan></text> <path sodipodi:nodetypes="ccccc" inkscape:connector-curvature="0" id="path1188" - d="m 181.95779,69.420536 h 57.15003 v 14.816663 h -57.15003 z" + d="m 181.95779,85.295537 h 57.15003 V 100.1122 h -57.15003 z" style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#a9a9a9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.52916664;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" /> <path style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#b0e0e6;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.52916664;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" - d="m 181.42862,68.891369 h 57.15003 v 14.816667 h -57.15003 z" + d="m 181.42862,84.76637 h 57.15003 v 14.816667 h -57.15003 z" id="path1190" inkscape:connector-curvature="0" sodipodi:nodetypes="ccccc" /> @@ -455,16 +462,16 @@ xml:space="preserve" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52777767px;line-height:125%;font-family:mono;-inkscape-font-specification:mono;text-align:center;letter-spacing:7.3342495px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" x="210.10182" - y="77.272949" + y="93.147942" id="text1196"><tspan sodipodi:role="line" x="210.23412" - y="77.272949" + y="93.147942" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:sans-serif;-inkscape-font-specification:sans-serif;text-align:center;letter-spacing:0.26458332px;text-anchor:middle;stroke-width:0.26458332px" id="tspan1222">Jupyter Notebook</tspan></text> <path style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#a9a9a9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.52916664;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" - d="m 240.16616,85.295537 h 57.15003 V 100.1122 h -57.15003 z" + d="m 240.16616,101.17054 h 57.15003 v 14.81667 h -57.15003 z" id="path1198" inkscape:connector-curvature="0" sodipodi:nodetypes="ccccc" /> @@ -472,22 +479,22 @@ sodipodi:nodetypes="ccccc" inkscape:connector-curvature="0" id="path1200" - d="m 239.63699,84.76637 h 57.15003 v 14.816667 h -57.15003 z" + d="m 239.63699,100.64137 h 57.15003 v 14.81667 h -57.15003 z" style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#b0e0e6;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.52916664;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" /> <text id="text1206" - y="93.147942" + y="109.02293" x="268.19046" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52777767px;line-height:125%;font-family:mono;-inkscape-font-specification:mono;text-align:center;letter-spacing:7.3342495px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" xml:space="preserve"><tspan id="tspan1204" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:sans-serif;-inkscape-font-specification:sans-serif;text-align:center;letter-spacing:0.26458332px;text-anchor:middle;stroke-width:0.26458332px" - y="93.147942" + y="109.02293" x="268.32275" sodipodi:role="line">Biopython</tspan></text> <path style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#a9a9a9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.52916664;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" - d="M 65.541073,101.17054 H 297.31608 v 14.81667 H 65.541073 Z" + d="M 65.541073,101.17054 H 180.89941 v 14.81667 H 65.541073 Z" id="path1280" inkscape:connector-curvature="0" sodipodi:nodetypes="ccccc" /> @@ -495,40 +502,35 @@ sodipodi:nodetypes="ccccc" inkscape:connector-curvature="0" id="path1282" - d="M 65.011906,100.64137 H 296.78691 v 14.81667 H 65.011906 Z" - style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#f5f5f5;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.52916664;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" /> + d="M 65.011906,100.64137 H 180.37024 v 14.81667 H 65.011906 Z" + style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#f0fff0;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.52916664;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" /> <text id="text1286" y="108.96867" - x="168.56856" + x="110.36021" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52777767px;line-height:125%;font-family:mono;-inkscape-font-specification:mono;text-align:start;letter-spacing:7.3342495px;word-spacing:0px;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" xml:space="preserve"><tspan id="tspan1284" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:sans-serif;-inkscape-font-specification:sans-serif;text-align:start;letter-spacing:0.26458332px;text-anchor:start;stroke-width:0.26458332px" y="108.96867" - x="168.56856" + x="110.36021" sodipodi:role="line">Lunch break</tspan></text> <path - sodipodi:nodetypes="ccccc" - inkscape:connector-curvature="0" - id="path1288" - d="M 65.541073,117.04555 H 297.31608 v 35.98334 H 65.541073 Z" - style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#a9a9a9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.52916664;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" /> - <path - style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#f5deb3;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.52916664;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" - d="M 65.011906,116.51638 H 296.78691 v 35.98334 H 65.011906 Z" + style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#f5deb3;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1.99999988;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" + d="m 140,300 v 60 16 160 h 876 V 360 H 576 v -60 z" + transform="matrix(0.26458333,0,0,0.26458333,27.970237,37.141367)" id="path1290" inkscape:connector-curvature="0" - sodipodi:nodetypes="ccccc" /> + sodipodi:nodetypes="ccccccccc" /> <text xml:space="preserve" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52777767px;line-height:125%;font-family:mono;-inkscape-font-specification:mono;text-align:start;letter-spacing:7.3342495px;word-spacing:0px;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" x="164.12988" - y="135.82321" + y="151.69823" id="text1294"><tspan sodipodi:role="line" x="164.12988" - y="135.82321" + y="151.69823" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:sans-serif;-inkscape-font-specification:sans-serif;text-align:start;letter-spacing:0.26458332px;text-anchor:start;stroke-width:0.26458332px" id="tspan1292">Practical session</tspan></text> <path @@ -643,5 +645,103 @@ y="47.992485" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:sans-serif;-inkscape-font-specification:sans-serif;text-align:center;letter-spacing:0.26458332px;text-anchor:middle;fill:#000000;stroke-width:0.26458332px" id="tspan1369">30/11</tspan></text> + <path + sodipodi:nodetypes="ccccc" + inkscape:connector-curvature="0" + id="path915" + d="m 181.95779,53.545535 h 57.15003 v 14.816667 h -57.15003 z" + style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#a9a9a9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.52916664;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" /> + <path + style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#b0e0e6;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.52916664;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" + d="m 181.42862,53.016368 h 57.15003 v 14.816667 h -57.15003 z" + id="path917" + inkscape:connector-curvature="0" + sodipodi:nodetypes="ccccc" /> + <text + xml:space="preserve" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52777767px;line-height:125%;font-family:mono;-inkscape-font-specification:mono;text-align:center;letter-spacing:7.3342495px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + x="210.0648" + y="61.397942" + id="text921"><tspan + sodipodi:role="line" + x="210.1971" + y="61.397942" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:sans-serif;-inkscape-font-specification:sans-serif;text-align:center;letter-spacing:0.26458332px;text-anchor:middle;stroke-width:0.26458332px" + id="tspan919">Assignments review</tspan></text> + <path + style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#a9a9a9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.52916664;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" + d="m 240.16616,53.545535 h 57.15003 v 14.816667 h -57.15003 z" + id="path923" + inkscape:connector-curvature="0" + sodipodi:nodetypes="ccccc" /> + <path + sodipodi:nodetypes="ccccc" + inkscape:connector-curvature="0" + id="path925" + d="m 239.63699,53.016368 h 57.15003 v 14.816667 h -57.15003 z" + style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#b0e0e6;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.52916664;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" /> + <text + id="text929" + y="61.397942" + x="268.27316" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52777767px;line-height:125%;font-family:mono;-inkscape-font-specification:mono;text-align:center;letter-spacing:7.3342495px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + xml:space="preserve"><tspan + id="tspan927" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:sans-serif;-inkscape-font-specification:sans-serif;text-align:center;letter-spacing:0.26458332px;text-anchor:middle;stroke-width:0.26458332px" + y="61.397942" + x="268.40546" + sodipodi:role="line">Assignments review</tspan></text> + <path + sodipodi:nodetypes="ccccc" + inkscape:connector-curvature="0" + id="path931" + d="m 181.95779,117.04555 h 115.35836 v 14.81667 H 181.95779 Z" + style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#a9a9a9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.52916664;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" /> + <path + style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#f0fff0;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.52916664;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" + d="m 181.42862,116.51638 h 115.35836 v 14.81667 H 181.42862 Z" + id="path933" + inkscape:connector-curvature="0" + sodipodi:nodetypes="ccccc" /> + <text + xml:space="preserve" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52777767px;line-height:125%;font-family:mono;-inkscape-font-specification:mono;text-align:start;letter-spacing:7.3342495px;word-spacing:0px;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + x="226.77695" + y="124.84368" + id="text937"><tspan + sodipodi:role="line" + x="226.77695" + y="124.84368" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:sans-serif;-inkscape-font-specification:sans-serif;text-align:start;letter-spacing:0.26458332px;text-anchor:start;stroke-width:0.26458332px" + id="tspan935">Lunch break</tspan></text> + <path + style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#a9a9a9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.52916664;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" + d="m 28.499404,117.04555 h 35.983321 v 14.81667 H 28.499404 Z" + id="path939" + inkscape:connector-curvature="0" + sodipodi:nodetypes="ccccc" /> + <path + sodipodi:nodetypes="ccccc" + inkscape:connector-curvature="0" + id="path941" + d="m 27.970237,116.51638 h 35.983318 v 14.81667 H 27.970237 Z" + style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#f5f5f5;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.52916664;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" /> + <text + id="text945" + y="125.20885" + x="30.693922" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:3.52777767px;line-height:125%;font-family:mono;-inkscape-font-specification:mono;text-align:start;letter-spacing:7.3342495px;word-spacing:0px;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + xml:space="preserve"><tspan + id="tspan943" + style="text-align:start;letter-spacing:0.26458332px;text-anchor:start;stroke-width:0.26458332px" + y="125.20885" + x="30.693922" + sodipodi:role="line">13:00 - 14:00</tspan></text> + <path + sodipodi:nodetypes="ccccc" + inkscape:connector-curvature="0" + id="path963" + d="M 65.011953,164.14141 H 296.78698 v 14.81667 H 65.011953 Z" + style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#f5f5f5;fill-opacity:0.53048778;fill-rule:evenodd;stroke:none;stroke-width:0.52916664;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" /> </g> </svg> diff --git a/introduction/flow_control/flow_control.pdf b/introduction/flow_control/flow_control.pdf new file mode 100644 index 0000000000000000000000000000000000000000..0cdce31eb7729b037ddcc85bd9325f12902579d6 Binary files /dev/null and b/introduction/flow_control/flow_control.pdf differ diff --git a/introduction/flow_control/flow_control.tex b/introduction/flow_control/flow_control.tex index 00d513c6216f87e99a7482307a55f30685bca76c..429847637f5cfd5885d1c43f9450f439a20d9c4e 100644 --- a/introduction/flow_control/flow_control.tex +++ b/introduction/flow_control/flow_control.tex @@ -137,15 +137,16 @@ IPython gives you a third option: \begin{itemize} - \item As an argument of the \lstinline{%run} magic. + \item As an argument of the \texttt{\%run} magic. \end{itemize} \end{pframe} \subsection{Writing your script} \begin{pframe} - Let's start with a simple GC calculator. Open your text editor, and write the - following Python statements (remember your indentations): + Let's start with a simple hello world example.\\ + + Open your text editor and write the following Python statement: \begin{pythonfile}{first\_script.py} \begin{minted}[linenos]{python} @@ -157,12 +158,9 @@ Save the file as first\_script.py and go to your shell. \subsection{Running the script} \begin{pframe} - Let's try the first method: using your script as an argument: + Let's try the first method, i.e., using your script as an argument: \begin{terminal} - \color{white}{ - \begin{lstlisting}[frame=,style=,numbers=none] -$ python first_script.py - \end{lstlisting}} + \color{white}{\texttt{\$ python first\_script.py}} \end{terminal} Is the output as you expect? \end{pframe} @@ -178,17 +176,11 @@ $ python first_script.py \item Save the file, go back to the shell, and allow the file to be executed. \end{itemize} \begin{terminal} - \color{white}{ - \begin{lstlisting}[frame=,style=,numbers=none] -$ chmod +x first_script.py - \end{lstlisting}} + \color{white}{\texttt{\$ chmod +x first\_script.py} \end{terminal} You can now execute the file directly: \begin{terminal} - \color{white}{ - \begin{lstlisting}[frame=,style=,numbers=none] -$ ./first_script.py - \end{lstlisting}} + \color{white}{\texttt{\$ ./first\_script.py}} \end{terminal} Is the output the same as the previous method? \end{pframe} @@ -197,7 +189,7 @@ $ ./first_script.py Finally, try out the third method. Open an IPython interpreter session and do: \begin{ipython} \begin{pythonin}{python} -%run seq_toolbox.py +%run first_script.py \end{pythonin} \end{ipython} \end{pframe} @@ -207,23 +199,20 @@ $ ./first_script.py \subsection{if statements} \begin{pframe} - \begin{pythonfile}{if.py} + \begin{pythonfile}{if\_example.py} \begin{minted}[linenos]{python} if 26 <= 17: print('Fact: 26 is less than or equal to 17') elif (26 + 8 > 14) == True: - print('Did we need the ` == True` part here?') + print("Did we need the ' == True' part here?") else: print('Nothing seems true') \end{minted} \end{pythonfile} \begin{terminal} - \color{white}{ - \begin{lstlisting}[frame=,style=,numbers=none] -$ python if.py -Did we need the ` == True` part here? - \end{lstlisting}} + \color{white}{\texttt{\$ python if\_example.py}\\ + \texttt{Did we need the ' == True' part here?}} \end{terminal} \end{pframe} @@ -232,7 +221,7 @@ Did we need the ` == True` part here? \subsection{while statements} \begin{pframe} - \begin{pythonfile}{while.py} + \begin{pythonfile}{while\_example.py} \begin{minted}[linenos]{python} i = 0 while i < 5: @@ -242,21 +231,18 @@ while i < 5: \end{pythonfile} \begin{terminal} - \color{white}{ - \begin{lstlisting}[frame=,style=,numbers=none] -$ python while.py -0 -1 -2 -3 -4 - \end{lstlisting}} + \color{white}{\texttt{\$ python while\_example.py \\ +0\\ +1\\ +2\\ +3\\ +4\\}} \end{terminal} \end{pframe} \subsection{Iterating over a sequence} \begin{pframe} - \begin{pythonfile}{for.py} + \begin{pythonfile}{for\_example.py} \begin{minted}[linenos]{python} colors = ['red', 'white', 'blue', 'orange'] cities = ['leiden', 'utrecht', 'warmond', 'san francisco'] @@ -273,21 +259,118 @@ for character in 'blue': \begin{pframe} \begin{terminal} - \color{white}{ - \begin{lstlisting}[frame=,style=,numbers=none] -$ python for.py -red -white -blue -orange -b -l -u -e \end{lstlisting}} + \color{white}{\texttt{\$ python for\_example.py\\ +red\\ +white\\ +blue\\ +orange\\ +b\\ +l\\ +u\\ +e\\ +}} \end{terminal} \end{pframe} +\subsection{Python anti-patterns} +\begin{pframe} +These are common for programmers coming from other languages. + \begin{pythonfile}{unpythonic.py} + \begin{minted}[linenos]{python} +i = 0 +while i < len(colors): + print colors[i] + i += 1 + +for i in range(len(colors)): + print colors[i] + \end{minted} + \end{pythonfile} + +We call them unpythonic. +\end{pframe} + + +\subsection{Additionals} +\begin{pframe} + \begin{pythonfile}{iteration.py} + \begin{minted}[linenos]{python} +# Iteration with values and indices: +for i, color in enumerate(colors): + print(i, '->', color) + +# Taking two sequences together: +for city, color in zip(cities, colors): + print(city, '->', color) + +# Iterating over a dictionary yields keys: +for key in {'a': 33, 'b': 17, 'c': 18}: + print(key) + +# Iterating over a file yields lines: +for line in open('data/short_file.txt'): + print(line) + \end{minted} + \end{pythonfile} +\end{pframe} + + + +\section{Notes about syntax} + +\subsection{Indentation} +\begin{pframe} + Python uses indentation to delimit blocks + \begin{itemize} + \item Instead of \texttt{begin ... end} or \texttt{\{ ... \}} in other languages. + \item Always increase indentation by 4 spaces, never use tabs. + \begin{itemize} + \item In any case, be consistent. + \end{itemize} + \end{itemize} + \begin{pythonfile}{indentation\_example.py} + \begin{minted}[linenos]{python} +if False: + if False: + print 'Why am I here?' + else: + while True: + print 'When will it stop?' + print "And we're back to the first indentation level" + \end{minted} + \end{pythonfile} +\end{pframe} + + +\subsection{Comments} +\begin{pframe} + Comments are prepended by \texttt{\#} and completely ignored. + \begin{pythonfile}{comments\_example.py} + \begin{minted}[linenos]{python} +# Create the list. +l = [] + +# Add 42 to this list. +l.append(42) + \end{minted} + \end{pythonfile} +\end{pframe} + + +\subsection{The pass statement} +\begin{pframe} + If you ever need a statement syntactically but don't want to do anything, use \texttt{pass}. + \begin{pythonfile}{comments\_example.py} + \begin{minted}[linenos]{python} +while False: + # This is never executed anyway. + pass + \end{minted} + \end{pythonfile} +\end{pframe} + + \section{Functions} @@ -318,11 +401,11 @@ for i in range(5): def add_some_other_number(number, other_number=12): return number + other_number -add_some_other_number(2, 6) +add_some_other_number(2, 6) # 8 -add_some_other_number(3, other_number=4) +add_some_other_number(3, other_number=4) # 7 -add_some_other_number(5) +add_some_other_number(5) # 17 \end{minted} \end{pythonfile} \end{pframe} @@ -333,6 +416,12 @@ add_some_other_number(5) We can pass functions around just like other values, and call them. \begin{pythonfile}{function\_values.py} \begin{minted}[linenos]{python} +def add_two(number): + return number + 2 + +def add_some_other_number(number, other_number=12): + return number + other_number + functions = [add_two, add_some_other_number] for function in functions: print function(7) @@ -346,6 +435,7 @@ for function in functions: \end{pframe} + \subsection{Docstrings} \begin{pframe} Like many other definitions, functions can have docstrings. @@ -354,12 +444,25 @@ for function in functions: body with. \item You can access an object's docstring using help. \end{itemize} + \begin{pythonfile}{docstring\_example.py} + \begin{minted}[linenos]{python} +def factorial(n): + """Compute factorial of n in the obious way.""" + if n == 0: + return 1 + else: + return factorial(n - 1) * n + \end{minted} + \end{pythonfile} +\end{pframe} +\subsection{Higher-order functions} +\begin{pframe} + A function that takes a function as argument is a higher-order function. \begin{ipython} \begin{pythonin}{python} help(map) Help on class map in module builtins: - class map(object) | map(func, *iterables) --> map object | @@ -379,6 +482,71 @@ list(map(add_two, [1, 2, 3, 4])) \end{pframe} + +\section{Comprehensions} + +\subsection{List comprehensions} +\begin{pframe} + Similar to mathematical set notation (e.g., ${x | x \in R \wedge x>0}$), we can create lists. + \begin{ipython} + \begin{pythonin}{python} +[(x, x * x) for x in range(10) if x % 2] + \end{pythonin} + \\ + + \begin{pythonout}{python} +[(1, 1), (3, 9), (5, 25), (7, 49), (9, 81)] + \end{pythonout} + \end{ipython} + +We can do the same thing using \texttt{map} and \texttt{filter}, but list comprehensions are often more readable. + + \begin{ipython} + \begin{pythonin}{python} +list(map(lambda x: (x, x * x), filter(lambda x: x %2, range(10)))) + \end{pythonin} + \\ + + \begin{pythonout}{python} +[(1, 1), (3, 9), (5, 25), (7, 49), (9, 81)] + \end{pythonout} + \end{ipython} +\end{pframe} + +\subsection{Set and dictionary comprehensions} +\begin{pframe} + Similar notation can be used for (non-empty) sets. + \begin{ipython} + \begin{pythonin}{python} +{c for c in 'LUMC-standard' if 'a' <= c <= 'z'} + \end{pythonin} + \\ + + \begin{pythonout}{python} +{'a', 'd', 'n', 'r', 's', 't'} + \end{pythonout} + \end{ipython} + +We can do the same thing using \texttt{map} and \texttt{filter}, but list comprehensions are often more readable. + + \begin{ipython} + \begin{pythonin}{python} +colors = ['red', 'white', 'blue', 'orange'] + \end{pythonin} + \\ + \begin{pythonin}{python} +{c: len(c) for c in colors} + \end{pythonin} + \\ + + \begin{pythonout}{python} +{'blue': 4, 'orange': 6, 'red': 3, 'white': 5} + \end{pythonout} + \end{ipython} +\end{pframe} + + + \section{Hands on!} \begin{pframe} \vspace{-0.5cm} @@ -388,7 +556,7 @@ list(map(add_two, [1, 2, 3, 4])) Try to reuse the first maximum of two numbers function. \item Write a Python function that accepts a string as parameter. Next, it calculates and prints the number of upper case letters and lower - case letters. Make us of the \mintinline{python}{isupper} and + case letters. Make use of the \mintinline{python}{isupper} and \mintinline{python}{islower} built in methods.