conditional
authorMart Lubbers <mart@martlubbers.net>
Fri, 4 Mar 2016 09:49:41 +0000 (10:49 +0100)
committerMart Lubbers <mart@martlubbers.net>
Fri, 4 Mar 2016 09:49:41 +0000 (10:49 +0100)
Makefile
p.tex

index 9f55cf5..798a4ca 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,7 @@ DOCUMENT:=p
 
 all: $(DOCUMENT).pdf
 
-%.pdf: %.tex %.fmt 
+%.pdf: %.tex %.fmt
        $(LATEX) -shell-escape $(basename $@)
        $(LATEX) -shell-escape $(basename $@)
 
@@ -14,4 +14,5 @@ all: $(DOCUMENT).pdf
        $(LATEX) -ini -shell-escape -jobname="$(basename $@)" "&$(LATEX) $<\dump"
 
 clean:
-       $(RM) -v $(addprefix $(DOCUMENT)., aux fmt log nav out pdf snm toc vrb)
+       $(RM) -rv $(addprefix $(DOCUMENT)., aux fmt log nav out pdf snm toc vrb)\
+               _minted-p
diff --git a/p.tex b/p.tex
index b338e76..cce1750 100644 (file)
--- a/p.tex
+++ b/p.tex
@@ -22,7 +22,7 @@
 \begin{frame}[fragile]
        \frametitle{How to start}
        \framesubtitle{Interpreter}
-       \begin{minted}[breaklines]{pycon}
+       \begin{minted}[breaklines=true]{pycon}
 Python 3.5.1 (default, Dec  7 2015, 12:58:09) 
 [GCC 5.2.0] on linux
 Type "help", "copyright", "credits" or "license" for more
@@ -52,16 +52,21 @@ print(str(i/46) + ' hoi')
 \begin{frame}[fragile]
        \frametitle{Basictypes}
        \begin{block}{types}
-               \begin{itemize}
-                       \item \mint{python}|int|
-                       \item \mint{python}|float|
-                       \item \mint{python}|str|
-                       \item \mint{python}|list|
-               \end{itemize}
+               \begin{tabular}{ll}
+                       \mintinline{python}{bool} & \mintinline{python}{True, False}\\
+                       \mintinline{python}{int} & \mintinline{python}{1, -4, 999}\\
+                       \mintinline{python}{complex} & \mintinline{python}{4j+1, j}\\
+                       \mintinline{python}{float} & \mintinline{python}
+                               {1.0, 4.5, 5e9, float('NaN'), float('inf')}\\
+                       \mintinline{python}{str} & \mintinline{python}
+                               {'hi', "hi", '"', "'", """hi"""}\\
+                       \mintinline{python}{list} & \mintinline{python}
+                               {[], ..., [1, 2, 3], ['a', 42], [[], [1]]}
+               \end{tabular}
        \end{block}
        \begin{block}{operators}
                \begin{itemize}
-                       \item Numbers: \mintinline{python}{+ - / * // \% @ **}
+                       \item Numbers: \mintinline{python}{+ - / * // % @ **}
                        \item Comparison: \mintinline{python}{< <= > >= == != is}
                        \item Boolean: \mintinline{python}{and or not}
                        \item Bitwise: \mintinline{python}{& | ^ ~ << >>}
@@ -72,10 +77,48 @@ print(str(i/46) + ' hoi')
 \end{frame}
 
 \section{Control flow}
+\subsection{If, then, else}
+\begin{frame}[fragile]
+       \frametitle{Conditional execution}
+       \framesubtitle{\texttt{fizzbuzz.py}}
+       \begin{minted}{python}
+#!/usr/bin/env python3
+
+i = int(input('Enter a number: '))
+if i % 3 == 0 and i % 5 == 0:
+    print('fizzbuzz')
+elif i % 3 == 0:
+    print('buzz')
+elif i % 5 == 0:
+    print('fizz')
+else:
+    print(i)
+       \end{minted}
+\end{frame}
+
 \begin{frame}[fragile]
-       \frametitle{}
+       \frametitle{Conditional execution 2}
+       \framesubtitle{\texttt{fizzbuzz.py}}
+       \begin{minted}{shell-session}
+frobnicator@frobmachine~$ python fizzbuzz.py
+Enter a number: 42
+buzz
+frobnicator@frobmachine~$ python fizzbuzz.py
+Enter a number: 15
+fizzbuzz
+frobnicator@frobmachine~$ python fizzbuzz.py
+Enter a number: 43
+43
+frobnicator@frobmachine~$ python fizzbuzz.py
+Enter a number: 9
+fizz
+       \end{minted}
 \end{frame}
 
+\subsection{While, for}
+
+\subsection{Functions}
+
 \section{Datastructures}
 
 \section{Input/Output}