miroir de
https://github.com/PAPAMICA/Wiki-Tech.io.git
synchronisé 2024-07-13 13:22:23 +02:00
docs: create Python/Boucles
Cette révision appartient à :
Parent
06070fe64a
révision
34fbf4d71a
25
Python/Boucles.html
Fichier normal
25
Python/Boucles.html
Fichier normal
|
@ -0,0 +1,25 @@
|
||||||
|
<!--
|
||||||
|
title: Les boucles
|
||||||
|
description:
|
||||||
|
published: true
|
||||||
|
date: 2021-04-28T19:40:54.892Z
|
||||||
|
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>
|
||||||
|
<p><strong>Attention</strong> : Il ne faut pas oublier d'incrémenter le compteur, sinon la boucle sera infinie !</p>
|
||||||
|
</blockquote>
|
Chargement…
Référencer dans un nouveau ticket