Dictionary added master
authorMart Lubbers <mart@martlubbers.net>
Tue, 8 Mar 2016 08:42:43 +0000 (09:42 +0100)
committerMart Lubbers <mart@martlubbers.net>
Tue, 8 Mar 2016 08:42:43 +0000 (09:42 +0100)
p.tex

diff --git a/p.tex b/p.tex
index 9ebb806..dc09889 100644 (file)
--- a/p.tex
+++ b/p.tex
@@ -254,11 +254,37 @@ True
                \mintinline{python}{lst.clear(x)} &
                        \mintinline{python}{lst = []}\\
                \mintinline{python}{lst.reverse(x)} &
-                       \mintinline{python}{reverse(lst)}\\
+                       \mintinline{python}{reversed(lst)}\\
+               \mintinline{python}{lst.sort(x)} &
+                       \mintinline{python}{sorted(lst)}\\
                \ldots
        \end{tabular}
 \end{frame}
 
+\begin{frame}[fragile]
+       \frametitle{Dictionary}
+       \begin{minted}{pycon}
+>>> tel = {'jack': 4098, 'sape': 4139}
+>>> tel['guido'] = 4127
+>>> tel
+{'sape': 4139, 'guido': 4127, 'jack': 4098}
+>>> tel['jack']
+4098
+>>> del tel['sape']
+>>> tel['irv'] = 4127
+>>> tel
+{'guido': 4127, 'irv': 4127, 'jack': 4098}
+>>> list(tel.keys())
+['irv', 'guido', 'jack']
+>>> sorted(tel.keys())
+['guido', 'irv', 'jack']
+>>> 'guido' in tel
+True
+>>> 'jack' not in tel
+False
+       \end{minted}
+\end{frame}
+
 \begin{frame}[fragile]
        \frametitle{Sequences}
        \begin{block}{Tuples}