|
@@ -1,4 +1,3 @@ |
|
|
% !TEX encoding = UTF-8 Unicode |
|
|
|
|
|
\documentclass{beamer} |
|
|
\documentclass{beamer} |
|
|
|
|
|
|
|
|
\usepackage[utf8]{inputenc} |
|
|
\usepackage[utf8]{inputenc} |
|
@@ -300,7 +299,7 @@ Avec la fonction \texttt{len()}: |
|
|
|
|
|
|
|
|
\vfill |
|
|
\vfill |
|
|
|
|
|
|
|
|
Astuce: l'index maximal est \texttt{len(list) -1}. Retenez-le :) |
|
|
|
|
|
|
|
|
Astuce: l'index maximal est \texttt{len(list) -1} ;) |
|
|
|
|
|
|
|
|
\end{frame} |
|
|
\end{frame} |
|
|
|
|
|
|
|
@@ -346,4 +345,149 @@ False |
|
|
|
|
|
|
|
|
\end{frame} |
|
|
\end{frame} |
|
|
|
|
|
|
|
|
|
|
|
\begin{frame}[fragile] |
|
|
|
|
|
\frametitle{Ajout d'un élément} |
|
|
|
|
|
Avec \texttt{append()} |
|
|
|
|
|
|
|
|
|
|
|
\begin{lstlisting} |
|
|
|
|
|
>>> fruits.append("poire") |
|
|
|
|
|
>>> fruits |
|
|
|
|
|
['pomme', 'banane', 'poire'] |
|
|
|
|
|
\end{lstlisting} |
|
|
|
|
|
|
|
|
|
|
|
\vfill |
|
|
|
|
|
|
|
|
|
|
|
Notez le point entre `fruits` et `append` |
|
|
|
|
|
\end{frame} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
\begin{frame}[fragile] |
|
|
|
|
|
\frametitle{Autres opérations} |
|
|
|
|
|
|
|
|
|
|
|
\begin{lstlisting} |
|
|
|
|
|
>>> fruits = ["pomme", "poire"] |
|
|
|
|
|
|
|
|
|
|
|
>>> fruits.insert(1, "abricot") |
|
|
|
|
|
# ['pomme', 'abricot', 'poire'] |
|
|
|
|
|
|
|
|
|
|
|
>>> fruits.remove("pomme") |
|
|
|
|
|
# ['abricot', 'poire'] |
|
|
|
|
|
>>> fruits.remove("pas un fruit") |
|
|
|
|
|
Erreur! |
|
|
|
|
|
\end{lstlisting} |
|
|
|
|
|
|
|
|
|
|
|
\end{frame} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
\begin{frame}[fragile] |
|
|
|
|
|
\frametitle{Dictionnaires} |
|
|
|
|
|
|
|
|
|
|
|
Des clés et des valeurs: |
|
|
|
|
|
|
|
|
|
|
|
\begin{lstlisting} |
|
|
|
|
|
>>> mon_dico = dict() # dictionaire vide |
|
|
|
|
|
>>> mon_dico = {} # aussi un dictionnaire vide |
|
|
|
|
|
|
|
|
|
|
|
# deux cles et deux valeurs: |
|
|
|
|
|
>>> scores = {"john": 24, "jane": 23} |
|
|
|
|
|
>>> scores.keys() |
|
|
|
|
|
["john", "jane" |
|
|
|
|
|
|
|
|
|
|
|
>>> mon_dico.values() |
|
|
|
|
|
[24, 23] |
|
|
|
|
|
\end{lstlisting} |
|
|
|
|
|
|
|
|
|
|
|
\end{frame} |
|
|
|
|
|
|
|
|
|
|
|
\begin{frame}[fragile] |
|
|
|
|
|
\frametitle{Insertion} |
|
|
|
|
|
\begin{lstlisting} |
|
|
|
|
|
>>> scores = {"john": 10 } |
|
|
|
|
|
>>> scores["john"] = 12 # John marque deux points |
|
|
|
|
|
>>> scores["bob"] = 3 # Bob entre dans la partie |
|
|
|
|
|
>>> scores["personne"] |
|
|
|
|
|
Erreur! |
|
|
|
|
|
\end{lstlisting} |
|
|
|
|
|
\end{frame} |
|
|
|
|
|
|
|
|
|
|
|
\begin{frame}[fragile] |
|
|
|
|
|
\frametitle{Fusion de dictionnaires} |
|
|
|
|
|
|
|
|
|
|
|
\begin{lstlisting} |
|
|
|
|
|
>>> s1 = {"john": 12, "bob": 2} |
|
|
|
|
|
>>> s2 = {"bob": 3, "charlie": 4} |
|
|
|
|
|
>>> s1.update(s2) |
|
|
|
|
|
>>> s1 |
|
|
|
|
|
{"john": 12, "bob": 3, "charlie": 4} |
|
|
|
|
|
\end{lstlisting} |
|
|
|
|
|
\end{frame} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
\begin{frame}[fragile] |
|
|
|
|
|
\frametitle{Destruction} |
|
|
|
|
|
|
|
|
|
|
|
\begin{lstlisting} |
|
|
|
|
|
>>> scores = {"john": 12, "bob": 23} |
|
|
|
|
|
>>> scores.pop("john") |
|
|
|
|
|
# {"bob': 23} |
|
|
|
|
|
\end{lstlisting} |
|
|
|
|
|
|
|
|
|
|
|
\end{frame} |
|
|
|
|
|
|
|
|
|
|
|
\begin{frame}[fragile] |
|
|
|
|
|
\frametitle{Ensembles} |
|
|
|
|
|
Des objets sans ordre ni doublons. |
|
|
|
|
|
|
|
|
|
|
|
Création avec la fonction \texttt{set()}: |
|
|
|
|
|
|
|
|
|
|
|
\begin{lstlisting} |
|
|
|
|
|
>>> sac = set() |
|
|
|
|
|
>>> sac = {} # oups, c'est un dictionnaire vide! |
|
|
|
|
|
|
|
|
|
|
|
>>> sac = {"one", "two"} # un set avec deux strings |
|
|
|
|
|
\end{lstlisting} |
|
|
|
|
|
\end{frame} |
|
|
|
|
|
|
|
|
|
|
|
\begin{frame}[fragile] |
|
|
|
|
|
\frametitle{Ajout d'un élement dans un ensoble} |
|
|
|
|
|
\begin{lstlisting} |
|
|
|
|
|
>>> sac = {"one", "two"} |
|
|
|
|
|
>>> sac.add("three"} |
|
|
|
|
|
# {"one", "two", "three"} |
|
|
|
|
|
>>> sac.add("one") |
|
|
|
|
|
# {"one", "two", "three"} # pas de changement |
|
|
|
|
|
\end{lstlisting} |
|
|
|
|
|
\end{frame} |
|
|
|
|
|
|
|
|
|
|
|
\begin{frame}[fragile] |
|
|
|
|
|
\frametitle{Autres opérations} |
|
|
|
|
|
\begin{lstlisting} |
|
|
|
|
|
>>> s1 = {"one", "two"} |
|
|
|
|
|
>>> s2 = {"one", "three"} |
|
|
|
|
|
# {"two"} |
|
|
|
|
|
\end{lstlisting} |
|
|
|
|
|
|
|
|
|
|
|
Aussi: |
|
|
|
|
|
|
|
|
|
|
|
\begin{itemize} |
|
|
|
|
|
\item \texttt{update()} |
|
|
|
|
|
\item \texttt{union()} |
|
|
|
|
|
\item \texttt{intersection()} |
|
|
|
|
|
\end{itemize} |
|
|
|
|
|
\end{frame} |
|
|
|
|
|
|
|
|
|
|
|
\begin{frame}[fragile] |
|
|
|
|
|
|
|
|
|
|
|
\begin{beamercolorbox}[sep=8pt,center,shadow=true,rounded=true]{title} |
|
|
|
|
|
Jeu du pendu |
|
|
|
|
|
\end{beamercolorbox} |
|
|
|
|
|
|
|
|
|
|
|
\end{frame} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
\end{document} |
|
|
\end{document} |