Feat: Bilan sur les conditions
This commit is contained in:
parent
dbb74b63b7
commit
5b7a35fb77
BIN
2nd/13_Programmation/3B_conditions.pdf
Normal file
BIN
2nd/13_Programmation/3B_conditions.pdf
Normal file
Binary file not shown.
39
2nd/13_Programmation/3B_conditions.tex
Normal file
39
2nd/13_Programmation/3B_conditions.tex
Normal file
@ -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}
|
@ -77,6 +77,11 @@ Traduction algo en français en programme en python
|
|||||||
|
|
||||||
`Conditions if <./3E_conditions.ipynb>`_
|
`Conditions if <./3E_conditions.ipynb>`_
|
||||||
|
|
||||||
|
.. image:: ./3B_conditions.pdf
|
||||||
|
:height: 200px
|
||||||
|
:alt: Les conditions
|
||||||
|
|
||||||
|
|
||||||
Étape 4: Boucle for
|
Étape 4: Boucle for
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user