diff --git a/2nd/13_Programmation/3B_conditions.pdf b/2nd/13_Programmation/3B_conditions.pdf new file mode 100644 index 0000000..59f6f30 Binary files /dev/null and b/2nd/13_Programmation/3B_conditions.pdf differ diff --git a/2nd/13_Programmation/3B_conditions.tex b/2nd/13_Programmation/3B_conditions.tex new file mode 100644 index 0000000..4b691a6 --- /dev/null +++ b/2nd/13_Programmation/3B_conditions.tex @@ -0,0 +1,39 @@ +\documentclass[a4paper,10pt]{article} +\usepackage{myXsim} + +\author{Benjamin Bertrand} +\title{Programmation - Cours} +\date{Février 2022} + +\pagestyle{empty} + +\begin{document} + +\maketitle +\setcounter{section}{2} + +\section{Conditions \lstinline{if/elif/else}} + +Quand on veut gérer différent cas de figure, on utilise les mots clés \lstinline{if/elif/else}. + +\begin{center} + \begin{minipage}{0.8\linewidth} + \begin{lstlisting} +age = str(input{Quel age as tu?}) +if age < 2: # si + print("Tu es un bébé") # alors +elif age < 18: #sinon si + print("Tu n'es pas majeur") # alors + print("Tu peux passer le permis") +elif age < 50: #sinon si + print("Tu as moins de la moitier d'un siècle") #alors +else: #sinon + print("Plus d'un demi siècle!") +print("J'ai plus rien à dire")\end{lstlisting} + \end{minipage} +\end{center} + +\paragraph{Remarque:} Il faut faire attention à l'indentation. C'est elle qui détermine où s'arrête le alors. + + +\end{document} diff --git a/2nd/13_Programmation/index.rst b/2nd/13_Programmation/index.rst index 0caf218..9a6c69b 100644 --- a/2nd/13_Programmation/index.rst +++ b/2nd/13_Programmation/index.rst @@ -77,6 +77,11 @@ Traduction algo en français en programme en python `Conditions if <./3E_conditions.ipynb>`_ +.. image:: ./3B_conditions.pdf + :height: 200px + :alt: Les conditions + + Étape 4: Boucle for -------------------