1
0
Bifurcation 0
miroir de https://github.com/PAPAMICA/Wiki-Tech.io.git synchronisé 2024-07-04 09:09:19 +02:00
Wiki-Tech.io/Python/Boucles.html
2021-05-20 15:12:13 +00:00

26 lignes
820 o
HTML

<!--
title: Les boucles
description:
published: true
date: 2021-05-20T14:35:10.117Z
tags:
editor: ckeditor
dateCreated: 2021-04-28T19:40:54.892Z
-->
<h1>Les boucles</h1>
<h2>La boucle <strong>WHILE</strong></h2>
<p>La boucle <strong>while</strong> (ou tant que) répète une série d'instruction tant qu'une condition n'est pas vraie.<br>Syntaxe :</p>
<pre><code class="language-python">while condition:
instruction1
instruction2
...</code></pre>
<p><i>Exemple : Je veux répéter une instruction tant que i n'est pas égal à 10 :</i></p>
<pre><code class="language-python">i = 0
while 1 != 10:
print ("i ne vaut pas 10")
i+=1</code></pre>
<blockquote class="is-warning">
<p><strong>Attention</strong> : Il ne faut pas oublier d'incrémenter le compteur, sinon la boucle sera infinie !</p>
</blockquote>