From: Mart Lubbers Date: Tue, 8 Mar 2016 08:42:43 +0000 (+0100) Subject: Dictionary added X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=refs%2Fheads%2Fmaster;p=linuxnijmegen-python.git Dictionary added --- diff --git a/p.tex b/p.tex index 9ebb806..dc09889 100644 --- 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}