Commit 519ebb17 authored by Mihai Lefter's avatar Mihai Lefter
Browse files

Introducion tex draft

parent c76d0065
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="120.96939mm"
height="21.43125mm"
viewBox="0 0 120.96939 21.43125"
version="1.1"
id="svg8"
inkscape:version="0.92.3 (unknown)"
sodipodi:docname="cwi.svg">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1.4"
inkscape:cx="254.9867"
inkscape:cy="69.553588"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="1920"
inkscape:window-height="1136"
inkscape:window-x="1280"
inkscape:window-y="27"
inkscape:window-maximized="1"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(74.825928,-155.93929)">
<path
style="fill:#c41230;fill-opacity:1;stroke-width:1"
d="m -69.138942,168.57314 c -2.172435,-4.83856 -4.34073,-9.66059 -4.818434,-10.71562 l -0.868552,-1.91823 h 24.070403 24.070403 v 6.48229 c 0,3.56526 -0.03299,6.48229 -0.07331,6.48229 -0.04032,0 -8.639362,1.905 -19.108985,4.23334 -10.469624,2.32833 -19.100022,4.23333 -19.178663,4.23333 -0.07864,0 -1.92043,-3.95883 -4.092866,-8.7974 z m 10.628338,0.0775 c 1.179992,-0.53568 1.512539,-1.16414 1.352913,-2.55677 -0.135369,-1.18099 -0.888064,-1.11764 -1.523668,0.12825 -0.56971,1.11672 -1.259006,1.50329 -2.241039,1.25682 -1.045854,-0.26249 -1.697824,-2.56004 -1.361978,-4.79963 0.226645,-1.51137 0.910079,-2.24206 2.097066,-2.24206 0.995017,0 1.356437,0.3113 1.630867,1.40472 0.140798,0.56098 0.322193,0.72084 0.748875,0.65997 0.4628,-0.066 0.591007,-0.3159 0.719942,-1.40324 0.08628,-0.7276 0.175576,-1.17408 0.198437,-0.99218 0.02286,0.1819 0.220161,0.33073 0.438442,0.33073 0.218282,0 0.396875,0.0636 0.396875,0.14135 0,0.70827 1.139476,7.54112 1.336105,8.01194 0.192753,0.46154 0.429648,0.59207 0.960359,0.52917 0.605264,-0.0717 0.781962,-0.3138 1.254534,-1.71857 0.302524,-0.89928 0.61678,-1.70023 0.698347,-1.7799 0.08157,-0.0797 0.415855,0.68588 0.742862,1.70121 0.55366,1.71906 0.646885,1.84605 1.355222,1.84605 0.929492,0 0.899793,0.0967 1.476618,-4.80806 0.400695,-3.40711 0.519292,-3.89842 0.96947,-4.01614 0.322287,-0.0843 0.478769,-0.31319 0.421032,-0.6159 -0.07645,-0.40082 -0.398254,-0.49508 -1.915014,-0.56092 -1.002717,-0.0435 -1.942986,0.0407 -2.089489,0.18722 -0.365,0.365 0.257127,1.08255 0.938591,1.08255 0.49217,0 0.515894,0.11991 0.353345,1.78593 -0.09584,0.98227 -0.243353,2.13669 -0.327814,2.56538 -0.148615,0.75431 -0.172234,0.73299 -0.732779,-0.66146 -0.471212,-1.17222 -0.695253,-1.4409 -1.201526,-1.4409 -0.508337,0 -0.707538,0.24229 -1.087664,1.32292 -0.255944,0.72761 -0.482425,1.26339 -0.503291,1.19063 -0.02087,-0.0728 -0.184957,-1.16892 -0.364647,-2.43591 -0.318251,-2.24397 -0.312662,-2.30562 0.215869,-2.38125 0.33024,-0.0472 0.575667,-0.31061 0.627127,-0.67295 0.08129,-0.57237 0.0074,-0.59531 -1.91823,-0.59531 -1.304447,0 -2.002777,0.10355 -2.002777,0.29698 0,0.20753 -0.117461,0.1995 -0.389962,-0.0267 -0.115669,-0.096 -0.178498,0.15304 -0.648395,0.0891 -0.468426,-0.0637 -1.343045,-0.44056 -2.015383,-0.45224 -1.799665,-0.11137 -2.029815,-0.30504 -3.162578,0.9277 -1.864364,2.02892 -1.965779,5.82798 -0.211239,7.91314 1.184547,1.40775 2.80823,1.67637 4.764575,0.78826 z m 18.464024,-0.40819 c 0,-0.43339 -0.20351,-0.54389 -1.124479,-0.61052 l -1.12448,-0.0814 v -3.54069 -3.54069 l 0.992188,-0.0821 c 0.788426,-0.0652 0.992187,-0.19079 0.992187,-0.61128 0,-0.49223 -0.201567,-0.53444 -2.887794,-0.60471 -2.959725,-0.0774 -3.473149,0.0559 -3.177987,0.82505 0.117898,0.30724 0.48188,0.44112 1.199298,0.44112 h 1.030025 v 3.57187 3.57188 h -1.042717 c -1.126596,0 -1.43373,0.2378 -1.175674,0.91029 0.141052,0.36758 0.604412,0.41826 3.242003,0.3546 2.876283,-0.0694 3.07743,-0.10886 3.07743,-0.60344 z"
id="path826"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cscccsssscccccccsccccsssccccsscsccscsssccsccsscscccccccccccsccscccssccc" />
<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:0.26458332px;word-spacing:0px;text-anchor:middle;fill:#696969;fill-opacity:1;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
x="10.772321"
y="159.41666"
id="text830"><tspan
sodipodi:role="line"
id="tspan828"
x="10.904614"
y="159.41666"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:monospace;-inkscape-font-specification:monospace;letter-spacing:0.26458332px;fill:#696969;stroke-width:0.26458332px">Centrum Wiskunde &amp; Informatica</tspan></text>
</g>
</svg>
This diff is collapsed.
This diff is collapsed.
\documentclass[slidestop]{beamer}
\documentclass[aspectratio=1610,slidestop]{beamer}
\author{Mihai Lefter}
\title{Python Programming}
\providecommand{\mySubTitle}{Introduction}
\providecommand{\myConference}{Work discussion}
\providecommand{\myConference}{Programming Course}
\providecommand{\myDate}{27-11-2018}
\providecommand{\myGroup}{}
\providecommand{\myDepartment}{}
......@@ -16,6 +16,8 @@
\usepackage[many]{tcolorbox}
\definecolor{monokaibg}{HTML}{272822}
\definecolor{emailc}{HTML}{1e90FF}
\newenvironment{ipython}
{\begin{tcolorbox}[title=IPython,
......@@ -32,124 +34,52 @@
{\end{tcolorbox}
}
\definecolor{white}{rgb}{1,1,1}
\definecolor{mygreen}{rgb}{0,0.4,0}
\definecolor{light_gray}{rgb}{0.97,0.97,0.97}
\definecolor{mykey}{rgb}{0.117,0.403,0.713}
\tcbuselibrary{listings}
\newlength\inwd
\setlength\inwd{1.3cm}
\newcounter{ipythcntr}
\renewcommand{\theipythcntr}{\texttt{[\arabic{ipythcntr}]}}
\newtcblisting{pyin}[1][]{%
sharp corners,
enlarge left by=\inwd,
width=\linewidth-\inwd,
enhanced,
boxrule=0pt,
colback=light_gray,
listing only,
top=0pt,
bottom=0pt,
overlay={
\node[
anchor=north east,
text width=\inwd,
font=\footnotesize\ttfamily\color{mykey},
inner ysep=2mm,
inner xsep=0pt,
outer sep=0pt
]
at (frame.north west)
{\refstepcounter{ipythcntr}\label{#1}In \theipythcntr:};
}
listing engine=listing,
listing options={
aboveskip=1pt,
belowskip=1pt,
basicstyle=\footnotesize\ttfamily,
language=Python,
keywordstyle=\color{mykey},
showstringspaces=false,
stringstyle=\color{mygreen},
numbers=none,
frame=none
},
}
\newtcblisting{pyprint}{
sharp corners,
enlarge left by=\inwd,
width=\linewidth-\inwd,
enhanced,
boxrule=0pt,
colback=white,
listing only,
top=0pt,
bottom=0pt,
overlay={
\node[
anchor=north east,
text width=\inwd,
font=\footnotesize\ttfamily\color{mykey},
inner ysep=2mm,
inner xsep=0pt,
outer sep=0pt
]
at (frame.north west)
{};
}
listing engine=listing,
listing options={
aboveskip=1pt,
belowskip=1pt,
basicstyle=\footnotesize\ttfamily,
language=Python,
keywordstyle=\color{mykey},
showstringspaces=false,
stringstyle=\color{mygreen},
numbers=none,
frame=none
},
}
\newtcblisting{pyout}[1][\theipythcntr]{
sharp corners,
enlarge left by=\inwd,
width=\linewidth-\inwd,
enhanced,
boxrule=0pt,
colback=white,
listing only,
top=0pt,
bottom=0pt,
overlay={
\node[
anchor=north east,
text width=\inwd,
font=\footnotesize\ttfamily\color{mykey},
inner ysep=2mm,
inner xsep=0pt,
outer sep=0pt
]
at (frame.north west)
{\setcounter{ipythcntr}{\value{ipythcntr}}Out#1:};
}
listing engine=listing,
listing options={
aboveskip=1pt,
belowskip=1pt,
basicstyle=\footnotesize\ttfamily,
language=Python,
keywordstyle=\color{mykey},
showstringspaces=false,
stringstyle=\color{mygreen},
numbers=none,
frame=none
},
}
\newcommand{\hrefcc}[2]{\textcolor{#1}{\href{#2}{#2}}}
\newcommand{\hrefc}[3]{\textcolor{#1}{\href{#2}{#3}}}
\newcounter{cntr}
\renewcommand{\thecntr}{\texttt{[\arabic{cntr}]}}
\newenvironment{pythonin}[1]
{\VerbatimEnvironment
\begin{minipage}[t]{0.11\linewidth}
\textcolor{green}{\texttt{{\refstepcounter{cntr}\label{#1}In \thecntr:}}}
\end{minipage}
\begin{minipage}[t]{0.89\linewidth}
\begin{minted}[
breaklines=true,style=monokai]{#1}}
{\end{minted}
\end{minipage}}
\newenvironment{pythonout}[1]
{\VerbatimEnvironment
\addtocounter{cntr}{-1}
\begin{minipage}[c]{0.11\linewidth}
\textcolor{red}{\texttt{{\refstepcounter{cntr}\label{#1}Out\thecntr:}}}
\end{minipage}
\begin{minipage}[c]{0.89\linewidth}
\begin{minted}[
breaklines=true,style=monokai]{#1}}
{\end{minted}
\end{minipage}}
\newenvironment{pythonerr}[1]
{\VerbatimEnvironment
\begin{minted}[
breaklines=true,style=monokai]{#1}}
{\end{minted}}
% \newenvironment{pythonout}[1]
% {\VerbatimEnvironment
% \addtocounter{cntr}{-1}
% \begin{minipage}[c]{0.13\linewidth}
% \textcolor{red}{\texttt{{\refstepcounter{cntr}\label{#1}Out\thecntr:}}}
% \end{minipage}
% \begin{minipage}[c]{0.87\linewidth}
% \color{gray}%
% }
% {\end{minipage}\\}
\begin{document}
......@@ -164,6 +94,7 @@
\section{Introduction}
\makeTableOfContents
\subsection{About the course}
\begin{pframe}
\begin{itemize}
......@@ -177,6 +108,7 @@
\end{itemize}
\end{pframe}
\subsection{Hands on!}
\begin{pframe}
Programming is fun!
......@@ -186,27 +118,47 @@
\begin{itemize}
\item Blended teaching + exercising.
\end{itemize}
\item Have your laptop open during the lessons.
\item Repeat the code from the slides, play around with it.
\item Have your laptop open during\\
the lessons.
\item Repeat the code from the slides,\\
play around with it.
\item Do the session exercises.
\item There will be a few assignments to submit.
\item There will be a few assignments.
\end{itemize}
\begin{tikzpicture}[remember picture,overlay]
\node[xshift=-4.5cm,yshift=-6.5cm] at (current page.north east)
{\includegraphics[width=6cm]{../../images/hands_on.jpg}};
\end{tikzpicture}
\end{pframe}
\subsection{Teachers}
\begin{pframe}
\begin{itemize}
\item Sander Bollen \\
\url{a.h.b.bollen@lumc.nl}
\item Jonathan Vis \\
\url{j.k.vis@lumc.nl}
\item Mark Santcroos \\
\url{m.a.santcroos@lumc.nl}
\item Guy Allard \\
\url{w.g.Allard@lumc.nl}
\item Mihai Lefter\\
\url{m.lefter@lumc.nl}
\end{itemize}
\begin{minipage}[t]{0.5\textwidth}
\begin{itemize}
\item Sander Bollen \\
\hrefcc{emailc}{a.h.b.bollen@lumc.nl}
\item Jonathan Vis \\
\hrefcc{emailc}{j.k.vis@lumc.nl}
\item Mark Santcroos \\
\hrefcc{emailc}{m.a.santcroos@lumc.nl}
\item Guy Allard \\
\hrefcc{emailc}{w.g.Allard@lumc.nl}
\item Mihai Lefter\\
\hrefcc{emailc}{m.lefter@lumc.nl}
\end{itemize}
\end{minipage}
\begin{tikzpicture}[remember picture,overlay]
\node[xshift=-5.0cm,yshift=-6.0cm] at (current page.north east)
{\includegraphics[width=7cm]{../../images/class.pdf}};
\end{tikzpicture}
\end{pframe}
\subsection{Program}
\begin{pframe}
\begin{center}
\includegraphics[width=\textwidth]{../../images/program.pdf}
\end{center}
\end{pframe}
\subsection{Software requirements}
......@@ -214,19 +166,29 @@
\begin{itemize}
\item Anaconda:
\begin{itemize}
\item Python 3.7
\item Python $3.7$.
\item Comes with all that's required:
\begin{itemize}
\item Python interpreter.
\item Jupyter Notebook.
\item Libraries: NumPy, Panda, matplotlib, Bokeh, Biopython, ...
\item Libraries: NumPy, Panda,\\
matplotlib, Bokeh, Biopython, ...
\end{itemize}
\item \href{http://docs.anaconda.com/anaconda/install/}{Installation instructions}.
\item \hrefc{emailc}{http://docs.anaconda.com/anaconda/install/}{Installation instructions}.
\end{itemize}
\bigskip
\item Git:
\begin{itemize}
\item \hrefc{emailc}{https://git-scm.com/book/en/v2/Getting-Started-Installing-Git}{Installation instructions}.
\end{itemize}
\item Git.
\end{itemize}
\begin{tikzpicture}[remember picture,overlay]
\node[xshift=-4.5cm,yshift=-5.5cm] at (current page.north east)
{\includegraphics[width=3cm]{../../images/requirements_logos.pdf}};
\end{tikzpicture}
\end{pframe}
\subsection{Assignments}
\begin{pframe}
\begin{itemize}
......@@ -238,21 +200,31 @@
\item Own forked repository to work on:
\begin{itemize}
\item Clone it.
\item Code.
\item Code it.
\item Push it.
\end{itemize}
\item Direct file upload to repository is also possible.
\item Direct file upload to repository\\
is also possible.
\end{itemize}
\begin{tikzpicture}[remember picture,overlay]
\node[xshift=-4.5cm,yshift=-6.5cm] at (current page.north east)
{\includegraphics[width=6cm]{../../images/assignments.jpg}};
\end{tikzpicture}
\end{pframe}
\subsection{Getting help}
\begin{pframe}
\begin{itemize}
\item Ask a teacher.
\item Ask a teacher (we will be around in the afternoon).
\item If it's private, mail one of the teachers.
\end{itemize}
\begin{center}
\includegraphics[width=0.54\textwidth]{../../images/help.jpg}
\end{center}
\end{pframe}
\section{About Python}
\subsection{History}
......@@ -265,8 +237,18 @@
\item General purpose, high-level programming language.
\item Design is driven by code readability.
\end{itemize}
\begin{tikzpicture}[remember picture,overlay]
\node[xshift=-4.5cm,yshift=-6.5cm] at (current page.north east)
{\includegraphics[width=6cm]{../../images/Guido.jpg}};
\end{tikzpicture}
\begin{tikzpicture}[remember picture,overlay]
\node[xshift=-11.5cm,yshift=-6.5cm] at (current page.north east)
{\includegraphics[width=6cm]{../../images/cwi.pdf}};
\end{tikzpicture}
\end{pframe}
\subsection{Features}
\begin{pframe}
\begin{itemize}
......@@ -281,6 +263,7 @@
We'll come back to most of this.
\end{pframe}
\subsection{Why Python?}
\begin{pframe}
\begin{itemize}
......@@ -291,16 +274,17 @@
\end{itemize}
\end{pframe}
\subsection{Python 2 versus Python 3}
\begin{pframe}
\begin{itemize}
\item Python 2.7 is the last Python 2.
\item Python 3 is backwards incompatible.
\item Some libraries don't support it yet.
\item Python 2.7 is the last Python 2.
\item Some Python 3 features are backported in Python 2.7.
\item Python 2.7 will no longer .
\item Python 2.7 will not be maintained past 2020.
\end{itemize}
We use Python 3.7 for the time being.
We'll use Python 3.7 for this course.
\end{pframe}
% \subsection{}
......@@ -312,78 +296,282 @@
\section{Python as a calculator}
\subsection{Integers}
\begin{pframe}
\begin{pyin}
\begin{ipython}
\begin{pythonin}{python}
17
\end{pyin}
\begin{pyout}
\end{pythonin}
\begin{pythonout}{python}
17
\end{pyout}
\begin{pyin}
\end{pythonout}
\\
\begin{pythonin}{python}
(17 + 4) * 2
\end{pyin}
\begin{pyout}
\end{pythonin}
\begin{pythonout}{python}
42
\end{pyout}
\end{pythonout}
\end{ipython}
\end{pframe}
\subsection{Floating point numbers}
\begin{pframe}
\begin{pyin}
\begin{ipython}
\begin{pythonin}{python}
3.2 * 18 - 2.1
\end{pyin}
\begin{pyout}
\end{pythonin}
\begin{pythonout}{python}
55.5
\end{pyout}
\begin{pyin}
36. / 5
\end{pyin}
\begin{pyout}
7.2
\end{pyout}
\end{pythonout}
\\
\begin{pythonin}{python}
36 / 5
\end{pythonin}
\begin{pythonout}{python}
7.2 # Note that this is Python 3 specific.
\end{pythonout}
\end{ipython}
\end{pframe}
\begin{pframe}
Scientific notation:
\begin{pyin}
\begin{ipython}
\begin{pythonin}{python}
1.3e20 + 2
\end{pyin}
\begin{pyout}
\end{pythonin}
\begin{pythonout}{python}
1.3e+20
\end{pyout}
\begin{pyin}
\end{pythonout}
\\
\begin{pythonin}{python}
1.3 * 10**20
\end{pyin}
\begin{pyout}
\end{pythonin}
\begin{pythonout}{python}
1.3e+20
\end{pythonout}
\end{ipython}
\end{pframe}
\section{Variables}
\begin{pframe}
\begin{itemize}
\item We can use names to reference values (variables).
\item No need to declare them first or define the type.
\end{itemize}
\begin{ipython}
\begin{pythonin}{python}
a = 1.3e20
\end{pythonin}
\\
\begin{pythonin}{python}
b = 2
\end{pythonin}
\\
\begin{pythonin}{python}
a
\end{pythonin}
\begin{pythonout}{python}
1.3e20
\end{pythonout}
\\
\begin{pythonin}{python}
c = a + 1.5e19 * b
\end{pythonin}
\\
\begin{pythonin}{python}
c * 2
\end{pythonin}
\begin{pythonout}{python}
3.2e+20
\end{pythonout}
\end{ipython}
\end{pframe}
\section{Python's type system}
\subsection{Every value has a type}
\begin{pframe}
\begin{itemize}
\item View it using \mintinline{python}{type}.
\end{itemize}
\begin{ipython}
\begin{pythonin}{python}
type(27)
\end{pythonin}
\begin{pythonout}{python}
int
\end{pythonout}
\\
\begin{pythonin}{python}
type(3 * 2)
\end{pythonin}
\begin{pythonout}{python}
int
\end{pythonout}
\\
\begin{pythonin}{python}
type(3 / 2)
\end{pythonin}