{"id":36,"date":"2025-09-07T18:46:25","date_gmt":"2025-09-07T16:46:25","guid":{"rendered":"https:\/\/yb-isn.fr\/2025\/nsi\/?p=36"},"modified":"2025-09-23T15:49:05","modified_gmt":"2025-09-23T13:49:05","slug":"4-python-conditions-et-boucles","status":"publish","type":"post","link":"https:\/\/yb-isn.fr\/2025\/nsi\/2025\/09\/07\/4-python-conditions-et-boucles\/","title":{"rendered":"4-Python :conditions et boucles"},"content":{"rendered":"\n<marquee> corrig\u00e9s des exercices d&rsquo;entrainement<\/marquee>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/capytale2.ac-paris.fr\/web\/c\/f134-3919478\">https:\/\/capytale2.ac-paris.fr\/web\/c\/f134-3919478<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Corrig\u00e9s des exercices euro dollar<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/capytale2.ac-paris.fr\/web\/c\/c8b6-1874602\">https:\/\/capytale2.ac-paris.fr\/web\/c\/c8b6-1874602<\/a><\/p>\n\n\n<p><!--more--><\/p>\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"has-black-color has-text-color has-background has-link-color wp-elements-29ae53a5ebee4ea269b72ecacce6096f wp-block-paragraph\" style=\"background:linear-gradient(135deg,rgb(216,244,179) 0%,rgb(17,184,81) 100%)\"><strong>1) Expression bool\u00e9enne<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Pour tester si une condition est vraie ou fausse il faut utiliser des expressions bool\u00e9ennes avec des op\u00e9rateurs de comparaison.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/yb-isn.fr\/2023\/nsi\/wp-content\/uploads\/2023\/09\/boucle1.jpg\" alt=\"\" class=\"wp-image-205\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<div class=\"wp-block-esab-accordion accordion-4f20ec4b\" data-mode=\"global\"><div class=\"esab__container\">\n<div class=\"wp-block-esab-accordion-child\"><div class=\"esab__head\" role=\"button\" aria-expanded=\"false\"><div class=\"esab__heading_txt\"><p class=\"esab__heading_tag\">\ud83c\udfcb\ufe0f Tester les diff\u00e9rentes expression bool\u00e9ennes ci-dessous dans une console python .Notez les r\u00e9ponses obtenues<\/p><\/div><div class=\"esab__icon\"><div class=\"esab__collapse\"> <svg version=\"1.2\" viewBox=\"0 0 24 24\" width=\"24\" height=\"24\"><path fill-rule=\"evenodd\" d=\"m3.5 20.5c-4.7-4.7-4.7-12.3 0-17 4.7-4.7 12.3-4.7 17 0 4.6 4.7 4.6 12.3 0 17-4.7 4.6-12.3 4.6-17 0zm0.9-0.9c4.2 4.2 11 4.2 15.2 0 4.2-4.2 4.2-11 0-15.2-4.2-4.3-11-4.3-15.2 0-4.3 4.2-4.3 11 0 15.2z\"><\/path><path d=\"m11.4 15.9v-3.3h-3.3c-0.3 0-0.6-0.3-0.6-0.6 0-0.4 0.3-0.6 0.6-0.6h3.3v-3.3c0-0.3 0.3-0.6 0.6-0.6 0.3 0 0.6 0.3 0.6 0.6v3.3h3.3c0.3 0 0.6 0.2 0.6 0.6q0 0.2-0.2 0.4-0.2 0.2-0.4 0.2h-3.3v3.3q0 0.2-0.2 0.4-0.2 0.2-0.4 0.2c-0.4 0-0.6-0.3-0.6-0.6z\"><\/path><\/svg> <\/div><div class=\"esab__expand\"> <svg version=\"1.2\" viewBox=\"0 0 24 24\" width=\"24\" height=\"24\"><path fill-rule=\"evenodd\" d=\"m12 24c-6.6 0-12-5.4-12-12 0-6.6 5.4-12 12-12 6.6 0 12 5.4 12 12 0 6.6-5.4 12-12 12zm10.6-12c0-5.9-4.7-10.6-10.6-10.6-5.9 0-10.6 4.7-10.6 10.6 0 5.9 4.7 10.6 10.6 10.6 5.9 0 10.6-4.7 10.6-10.6z\"><\/path><path d=\"m5.6 11.3h12.8v1.4h-12.8z\"><\/path><\/svg> <\/div><\/div><\/div><div class=\"esab__body\">\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/yb-isn.fr\/2023\/nsi\/wp-content\/uploads\/2023\/09\/image-3.png\" alt=\"\" class=\"wp-image-207\"\/><\/figure>\n<\/div><\/div>\n<\/div><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<div class=\"wp-block-esab-accordion accordion-5b30c71c\" data-mode=\"global\"><div class=\"esab__container\">\n<div class=\"wp-block-esab-accordion-child\"><div class=\"esab__head\" role=\"button\" aria-expanded=\"false\"><div class=\"esab__heading_txt\"><p class=\"esab__heading_tag\">\ud83c\udfcb\ufe0f On peut \u00e9crire des expressions plus \u00e9volu\u00e9es avec les op\u00e9rateurs logiques and  et or<br> Soient :   a=2   et   b=-3.<br>Pr\u00e9voir les r\u00e9sultats des expressions ci-dessous puis v\u00e9rifiez les r\u00e9sultats dans une console python.<\/p><\/div><div class=\"esab__icon\"><div class=\"esab__collapse\"> <svg version=\"1.2\" viewBox=\"0 0 24 24\" width=\"24\" height=\"24\"><path fill-rule=\"evenodd\" d=\"m3.5 20.5c-4.7-4.7-4.7-12.3 0-17 4.7-4.7 12.3-4.7 17 0 4.6 4.7 4.6 12.3 0 17-4.7 4.6-12.3 4.6-17 0zm0.9-0.9c4.2 4.2 11 4.2 15.2 0 4.2-4.2 4.2-11 0-15.2-4.2-4.3-11-4.3-15.2 0-4.3 4.2-4.3 11 0 15.2z\"><\/path><path d=\"m11.4 15.9v-3.3h-3.3c-0.3 0-0.6-0.3-0.6-0.6 0-0.4 0.3-0.6 0.6-0.6h3.3v-3.3c0-0.3 0.3-0.6 0.6-0.6 0.3 0 0.6 0.3 0.6 0.6v3.3h3.3c0.3 0 0.6 0.2 0.6 0.6q0 0.2-0.2 0.4-0.2 0.2-0.4 0.2h-3.3v3.3q0 0.2-0.2 0.4-0.2 0.2-0.4 0.2c-0.4 0-0.6-0.3-0.6-0.6z\"><\/path><\/svg> <\/div><div class=\"esab__expand\"> <svg version=\"1.2\" viewBox=\"0 0 24 24\" width=\"24\" height=\"24\"><path fill-rule=\"evenodd\" d=\"m12 24c-6.6 0-12-5.4-12-12 0-6.6 5.4-12 12-12 6.6 0 12 5.4 12 12 0 6.6-5.4 12-12 12zm10.6-12c0-5.9-4.7-10.6-10.6-10.6-5.9 0-10.6 4.7-10.6 10.6 0 5.9 4.7 10.6 10.6 10.6 5.9 0 10.6-4.7 10.6-10.6z\"><\/path><path d=\"m5.6 11.3h12.8v1.4h-12.8z\"><\/path><\/svg> <\/div><\/div><\/div><div class=\"esab__body\">\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/yb-isn.fr\/2023\/nsi\/wp-content\/uploads\/2023\/09\/image-4.png\" alt=\"\" class=\"wp-image-210\"\/><\/figure>\n<\/div><\/div>\n<\/div><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"has-black-color has-text-color has-background has-link-color wp-elements-c54ad0b53d0879672e4b7032fbd36cd1 wp-block-paragraph\" style=\"background:linear-gradient(135deg,rgb(216,244,179) 0%,rgb(17,184,81) 100%)\"><strong>2) Structure conditionnelle <strong>if<\/strong><\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">if test:\n    instruction(s)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">test est une expression bool\u00e9enne<br> l\u2019instruction ou les instructions ne seront ex\u00e9cut\u00e9es que si le r\u00e9sultat de l\u2019expression bool\u00e9enne est True.<br> La tabulation devant l\u2019instruction est indispensable. On parle d\u2019indentation.    <br> On peut ajouter un bloc d\u2019instructions si la condition n\u2019est pas v\u00e9rifi\u00e9e.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">if test :\n    instruction(s)\nelse :\n    autre(s) instruction(s)<\/pre>\n\n\n\n<div class=\"wp-block-esab-accordion accordion-195cf096\" data-mode=\"global\"><div class=\"esab__container\">\n<div class=\"wp-block-esab-accordion-child\"><div class=\"esab__head\" role=\"button\" aria-expanded=\"false\"><div class=\"esab__heading_txt\"><p class=\"esab__heading_tag\">\ud83c\udfcb\ufe0f \u00c9crire un programme qui converti des dollars en euro ou des euro en dollar selon le choix de l&rsquo;utilisateur<\/p><\/div><div class=\"esab__icon\"><div class=\"esab__collapse\"> <svg version=\"1.2\" viewBox=\"0 0 24 24\" width=\"24\" height=\"24\"><path fill-rule=\"evenodd\" d=\"m3.5 20.5c-4.7-4.7-4.7-12.3 0-17 4.7-4.7 12.3-4.7 17 0 4.6 4.7 4.6 12.3 0 17-4.7 4.6-12.3 4.6-17 0zm0.9-0.9c4.2 4.2 11 4.2 15.2 0 4.2-4.2 4.2-11 0-15.2-4.2-4.3-11-4.3-15.2 0-4.3 4.2-4.3 11 0 15.2z\"><\/path><path d=\"m11.4 15.9v-3.3h-3.3c-0.3 0-0.6-0.3-0.6-0.6 0-0.4 0.3-0.6 0.6-0.6h3.3v-3.3c0-0.3 0.3-0.6 0.6-0.6 0.3 0 0.6 0.3 0.6 0.6v3.3h3.3c0.3 0 0.6 0.2 0.6 0.6q0 0.2-0.2 0.4-0.2 0.2-0.4 0.2h-3.3v3.3q0 0.2-0.2 0.4-0.2 0.2-0.4 0.2c-0.4 0-0.6-0.3-0.6-0.6z\"><\/path><\/svg> <\/div><div class=\"esab__expand\"> <svg version=\"1.2\" viewBox=\"0 0 24 24\" width=\"24\" height=\"24\"><path fill-rule=\"evenodd\" d=\"m12 24c-6.6 0-12-5.4-12-12 0-6.6 5.4-12 12-12 6.6 0 12 5.4 12 12 0 6.6-5.4 12-12 12zm10.6-12c0-5.9-4.7-10.6-10.6-10.6-5.9 0-10.6 4.7-10.6 10.6 0 5.9 4.7 10.6 10.6 10.6 5.9 0 10.6-4.7 10.6-10.6z\"><\/path><path d=\"m5.6 11.3h12.8v1.4h-12.8z\"><\/path><\/svg> <\/div><\/div><\/div><div class=\"esab__body\">\n<p class=\"wp-block-paragraph\">Vous pourrez compl\u00e9ter le programme ci-dessous<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">dollar_euro=0.89\ndevise=input(\"entrez au clavier la monnaie \u00e0 convertir $ ou \u20ac: \")\nvaleur=float(input(\"entrez au clavier la valeur \u00e0 convertir : \"))\n\nif devise==\"$\":\n    resultat=\n\n\n\n    phrase='selon le cours du jour '+str(valeur)+' $ valent '+str(resultat)+' \u20ac'\n\nelse:  \n    resultat=\n\n\n\n    phrase='selon le cours du jour '+str(valeur)+' \u20ac valent '+str(resultat)+' $'\nprint(phrase)<\/pre>\n<\/div><\/div>\n<\/div><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Avec elif on peut tester plusieurs instructions avant de passer \u00e0 else<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">if test1 :\n    instruction(s) \n\nelif test2 :\n    instruction(s) \n\nelse :\n    autre(s) instruction(s)<\/pre>\n\n\n\n<div class=\"wp-block-esab-accordion accordion-7c4c47ae\" data-mode=\"global\"><div class=\"esab__container\">\n<div class=\"wp-block-esab-accordion-child\"><div class=\"esab__head\" role=\"button\" aria-expanded=\"false\"><div class=\"esab__heading_txt\"><p class=\"esab__heading_tag\">\ud83c\udfcb\ufe0f modifier le programme pr\u00e9c\u00e9dent en utilisant elif pour qu&rsquo;il affiche: je n&rsquo;ai pas compris votre saisie si le caract\u00e8re enregistr\u00e9 n&rsquo;est ni $ ni \u20ac<\/p><\/div><div class=\"esab__icon\"><div class=\"esab__collapse\"> <svg version=\"1.2\" viewBox=\"0 0 24 24\" width=\"24\" height=\"24\"><path fill-rule=\"evenodd\" d=\"m3.5 20.5c-4.7-4.7-4.7-12.3 0-17 4.7-4.7 12.3-4.7 17 0 4.6 4.7 4.6 12.3 0 17-4.7 4.6-12.3 4.6-17 0zm0.9-0.9c4.2 4.2 11 4.2 15.2 0 4.2-4.2 4.2-11 0-15.2-4.2-4.3-11-4.3-15.2 0-4.3 4.2-4.3 11 0 15.2z\"><\/path><path d=\"m11.4 15.9v-3.3h-3.3c-0.3 0-0.6-0.3-0.6-0.6 0-0.4 0.3-0.6 0.6-0.6h3.3v-3.3c0-0.3 0.3-0.6 0.6-0.6 0.3 0 0.6 0.3 0.6 0.6v3.3h3.3c0.3 0 0.6 0.2 0.6 0.6q0 0.2-0.2 0.4-0.2 0.2-0.4 0.2h-3.3v3.3q0 0.2-0.2 0.4-0.2 0.2-0.4 0.2c-0.4 0-0.6-0.3-0.6-0.6z\"><\/path><\/svg> <\/div><div class=\"esab__expand\"> <svg version=\"1.2\" viewBox=\"0 0 24 24\" width=\"24\" height=\"24\"><path fill-rule=\"evenodd\" d=\"m12 24c-6.6 0-12-5.4-12-12 0-6.6 5.4-12 12-12 6.6 0 12 5.4 12 12 0 6.6-5.4 12-12 12zm10.6-12c0-5.9-4.7-10.6-10.6-10.6-5.9 0-10.6 4.7-10.6 10.6 0 5.9 4.7 10.6 10.6 10.6 5.9 0 10.6-4.7 10.6-10.6z\"><\/path><path d=\"m5.6 11.3h12.8v1.4h-12.8z\"><\/path><\/svg> <\/div><\/div><\/div><div class=\"esab__body\">\n<p class=\"wp-block-paragraph\"><\/p>\n<\/div><\/div>\n<\/div><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"has-black-color has-text-color has-background has-link-color wp-elements-76102b51030f4b786b45cb0fb0da01c4 wp-block-paragraph\" style=\"background:linear-gradient(135deg,rgb(216,244,179) 0%,rgb(17,184,81) 100%)\"><strong>3) La boucle for<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>La boucle for<\/strong><br>La boucle for permet de faire des it\u00e9rations (r\u00e9p\u00e9titions) sur un \u00e9l\u00e9ment, comme une cha\u00eene de caract\u00e8res ou une liste. Le mot clef in v\u00e9rifie l\u2019appartenance d\u2019un \u00e9l\u00e9ment \u00e0 une s\u00e9quence.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">for i in liste :\n    Instruction(s)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<div class=\"wp-block-esab-accordion accordion-e6111e19\" data-mode=\"global\"><div class=\"esab__container\">\n<div class=\"wp-block-esab-accordion-child\"><div class=\"esab__head\" role=\"button\" aria-expanded=\"false\"><div class=\"esab__heading_txt\"><p class=\"esab__heading_tag\">\ud83c\udfcb\ufe0f pr\u00e9voir les r\u00e9sultats puis tester les 4 programmes suivants.<br>Commentez les r\u00e9sultats obtenus.<\/p><\/div><div class=\"esab__icon\"><div class=\"esab__collapse\"> <svg version=\"1.2\" viewBox=\"0 0 24 24\" width=\"24\" height=\"24\"><path fill-rule=\"evenodd\" d=\"m3.5 20.5c-4.7-4.7-4.7-12.3 0-17 4.7-4.7 12.3-4.7 17 0 4.6 4.7 4.6 12.3 0 17-4.7 4.6-12.3 4.6-17 0zm0.9-0.9c4.2 4.2 11 4.2 15.2 0 4.2-4.2 4.2-11 0-15.2-4.2-4.3-11-4.3-15.2 0-4.3 4.2-4.3 11 0 15.2z\"><\/path><path d=\"m11.4 15.9v-3.3h-3.3c-0.3 0-0.6-0.3-0.6-0.6 0-0.4 0.3-0.6 0.6-0.6h3.3v-3.3c0-0.3 0.3-0.6 0.6-0.6 0.3 0 0.6 0.3 0.6 0.6v3.3h3.3c0.3 0 0.6 0.2 0.6 0.6q0 0.2-0.2 0.4-0.2 0.2-0.4 0.2h-3.3v3.3q0 0.2-0.2 0.4-0.2 0.2-0.4 0.2c-0.4 0-0.6-0.3-0.6-0.6z\"><\/path><\/svg> <\/div><div class=\"esab__expand\"> <svg version=\"1.2\" viewBox=\"0 0 24 24\" width=\"24\" height=\"24\"><path fill-rule=\"evenodd\" d=\"m12 24c-6.6 0-12-5.4-12-12 0-6.6 5.4-12 12-12 6.6 0 12 5.4 12 12 0 6.6-5.4 12-12 12zm10.6-12c0-5.9-4.7-10.6-10.6-10.6-5.9 0-10.6 4.7-10.6 10.6 0 5.9 4.7 10.6 10.6 10.6 5.9 0 10.6-4.7 10.6-10.6z\"><\/path><path d=\"m5.6 11.3h12.8v1.4h-12.8z\"><\/path><\/svg> <\/div><\/div><\/div><div class=\"esab__body\">\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/yb-isn.fr\/2023\/nsi\/wp-content\/uploads\/2023\/09\/image-6.png\" alt=\"\" class=\"wp-image-231\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Python peut vous fournir la documentation sur une fonction gr\u00e2ce \u00e0 la commande help <\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" src=\"https:\/\/yb-isn.fr\/2023\/nsi\/wp-content\/uploads\/2023\/09\/image-8.png\" alt=\"\" class=\"wp-image-232\" style=\"width:597px;height:214px\"\/><\/figure>\n<\/div><\/div>\n<\/div><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<div class=\"wp-block-esab-accordion accordion-6a6e4e86\" data-mode=\"global\"><div class=\"esab__container\">\n<div class=\"wp-block-esab-accordion-child\"><div class=\"esab__head\" role=\"button\" aria-expanded=\"false\"><div class=\"esab__heading_txt\"><p class=\"esab__heading_tag\">\ud83c\udfcb\ufe0f \u00e9crire un programme qui converti des euros en dollar ou des dollars en euro selon le choix de l\u2019utilisateur \u00e0 l\u2019aide d\u2019une entr\u00e9e au clavier $ ou \u20ac. Modifier le programme pour qu\u2019il s\u2019arr\u00eate si la monnaie tap\u00e9e n\u2019est ni $ ni \u20ac. Donner la possibilit\u00e9 de faire 3 essais seulement.<\/p><\/div><div class=\"esab__icon\"><div class=\"esab__collapse\"> <svg version=\"1.2\" viewBox=\"0 0 24 24\" width=\"24\" height=\"24\"><path fill-rule=\"evenodd\" d=\"m3.5 20.5c-4.7-4.7-4.7-12.3 0-17 4.7-4.7 12.3-4.7 17 0 4.6 4.7 4.6 12.3 0 17-4.7 4.6-12.3 4.6-17 0zm0.9-0.9c4.2 4.2 11 4.2 15.2 0 4.2-4.2 4.2-11 0-15.2-4.2-4.3-11-4.3-15.2 0-4.3 4.2-4.3 11 0 15.2z\"><\/path><path d=\"m11.4 15.9v-3.3h-3.3c-0.3 0-0.6-0.3-0.6-0.6 0-0.4 0.3-0.6 0.6-0.6h3.3v-3.3c0-0.3 0.3-0.6 0.6-0.6 0.3 0 0.6 0.3 0.6 0.6v3.3h3.3c0.3 0 0.6 0.2 0.6 0.6q0 0.2-0.2 0.4-0.2 0.2-0.4 0.2h-3.3v3.3q0 0.2-0.2 0.4-0.2 0.2-0.4 0.2c-0.4 0-0.6-0.3-0.6-0.6z\"><\/path><\/svg> <\/div><div class=\"esab__expand\"> <svg version=\"1.2\" viewBox=\"0 0 24 24\" width=\"24\" height=\"24\"><path fill-rule=\"evenodd\" d=\"m12 24c-6.6 0-12-5.4-12-12 0-6.6 5.4-12 12-12 6.6 0 12 5.4 12 12 0 6.6-5.4 12-12 12zm10.6-12c0-5.9-4.7-10.6-10.6-10.6-5.9 0-10.6 4.7-10.6 10.6 0 5.9 4.7 10.6 10.6 10.6 5.9 0 10.6-4.7 10.6-10.6z\"><\/path><path d=\"m5.6 11.3h12.8v1.4h-12.8z\"><\/path><\/svg> <\/div><\/div><\/div><div class=\"esab__body\">\n<p class=\"wp-block-paragraph\">corrig\u00e9 \u00e0 venir<\/p>\n<\/div><\/div>\n<\/div><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"has-black-color has-text-color has-background has-link-color wp-elements-cbcb07cd74b7f1fbc223a6c4668c2ee1 wp-block-paragraph\" style=\"background:linear-gradient(135deg,rgb(216,244,179) 0%,rgb(17,184,81) 100%)\"> <strong>4) La boucle while<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>La boucle while<\/strong><br>En anglais \u00bb while \u00bb signifie \u00ab Tant que \u00bb. Pour cr\u00e9er une boucle , il faut donc utiliser ce mot cl\u00e9 suivi d\u2019une indication qui dit quand la boucle peut \u00e9ventuellement s\u2019arr\u00eater.Contrairement \u00e0 la boucle born\u00e9e for on a ici une boucle dite non born\u00e9e. <\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">while test :\n    instruction(s)<\/pre>\n\n\n\n<div class=\"wp-block-esab-accordion accordion-ee5dc10b\" data-mode=\"global\"><div class=\"esab__container\">\n<div class=\"wp-block-esab-accordion-child\"><div class=\"esab__head\" role=\"button\" aria-expanded=\"false\"><div class=\"esab__heading_txt\"><p class=\"esab__heading_tag\">\ud83c\udfcb\ufe0f \u00e9crire un programme qui converti des euros en dollar ou des dollars en euro selon le choix de l\u2019utilisateur \u00e0 l\u2019aide d\u2019une entr\u00e9e au clavier $ ou \u20ac. Modifier le programme pour qu\u2019il s\u2019arr\u00eate si la monnaie tap\u00e9e n\u2019est ni $ ni \u20ac. Donner la possibilit\u00e9 de faire un nombre infini d\u2019essais<\/p><\/div><div class=\"esab__icon\"><div class=\"esab__collapse\"> <svg version=\"1.2\" viewBox=\"0 0 24 24\" width=\"24\" height=\"24\"><path fill-rule=\"evenodd\" d=\"m3.5 20.5c-4.7-4.7-4.7-12.3 0-17 4.7-4.7 12.3-4.7 17 0 4.6 4.7 4.6 12.3 0 17-4.7 4.6-12.3 4.6-17 0zm0.9-0.9c4.2 4.2 11 4.2 15.2 0 4.2-4.2 4.2-11 0-15.2-4.2-4.3-11-4.3-15.2 0-4.3 4.2-4.3 11 0 15.2z\"><\/path><path d=\"m11.4 15.9v-3.3h-3.3c-0.3 0-0.6-0.3-0.6-0.6 0-0.4 0.3-0.6 0.6-0.6h3.3v-3.3c0-0.3 0.3-0.6 0.6-0.6 0.3 0 0.6 0.3 0.6 0.6v3.3h3.3c0.3 0 0.6 0.2 0.6 0.6q0 0.2-0.2 0.4-0.2 0.2-0.4 0.2h-3.3v3.3q0 0.2-0.2 0.4-0.2 0.2-0.4 0.2c-0.4 0-0.6-0.3-0.6-0.6z\"><\/path><\/svg> <\/div><div class=\"esab__expand\"> <svg version=\"1.2\" viewBox=\"0 0 24 24\" width=\"24\" height=\"24\"><path fill-rule=\"evenodd\" d=\"m12 24c-6.6 0-12-5.4-12-12 0-6.6 5.4-12 12-12 6.6 0 12 5.4 12 12 0 6.6-5.4 12-12 12zm10.6-12c0-5.9-4.7-10.6-10.6-10.6-5.9 0-10.6 4.7-10.6 10.6 0 5.9 4.7 10.6 10.6 10.6 5.9 0 10.6-4.7 10.6-10.6z\"><\/path><path d=\"m5.6 11.3h12.8v1.4h-12.8z\"><\/path><\/svg> <\/div><\/div><\/div><div class=\"esab__body\">\n<p class=\"wp-block-paragraph\">corrig\u00e9 \u00e0 venir<\/p>\n<\/div><\/div>\n<\/div><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<div class=\"wp-block-esab-accordion accordion-0770930e\" data-mode=\"global\"><div class=\"esab__container\">\n<div class=\"wp-block-esab-accordion-child\"><div class=\"esab__head\" role=\"button\" aria-expanded=\"false\"><div class=\"esab__heading_txt\"><p class=\"esab__heading_tag\">\ud83c\udfcb\ufe0f \u00e9crire un programme qui converti des euros en dollar ou des dollars en euro selon le choix de l\u2019utilisateur \u00e0 l\u2019aide d\u2019une entr\u00e9e au clavier $ ou \u20ac. Modifier le programme pour qu\u2019il s\u2019arr\u00eate si la monnaie tap\u00e9e n\u2019est ni $ ni \u20ac. Donner la possibilit\u00e9 de faire un nombre infini d\u2019essais et de pouvoir quitter en saisissant la lettre q.<\/p><\/div><div class=\"esab__icon\"><div class=\"esab__collapse\"> <svg version=\"1.2\" viewBox=\"0 0 24 24\" width=\"24\" height=\"24\"><path fill-rule=\"evenodd\" d=\"m3.5 20.5c-4.7-4.7-4.7-12.3 0-17 4.7-4.7 12.3-4.7 17 0 4.6 4.7 4.6 12.3 0 17-4.7 4.6-12.3 4.6-17 0zm0.9-0.9c4.2 4.2 11 4.2 15.2 0 4.2-4.2 4.2-11 0-15.2-4.2-4.3-11-4.3-15.2 0-4.3 4.2-4.3 11 0 15.2z\"><\/path><path d=\"m11.4 15.9v-3.3h-3.3c-0.3 0-0.6-0.3-0.6-0.6 0-0.4 0.3-0.6 0.6-0.6h3.3v-3.3c0-0.3 0.3-0.6 0.6-0.6 0.3 0 0.6 0.3 0.6 0.6v3.3h3.3c0.3 0 0.6 0.2 0.6 0.6q0 0.2-0.2 0.4-0.2 0.2-0.4 0.2h-3.3v3.3q0 0.2-0.2 0.4-0.2 0.2-0.4 0.2c-0.4 0-0.6-0.3-0.6-0.6z\"><\/path><\/svg> <\/div><div class=\"esab__expand\"> <svg version=\"1.2\" viewBox=\"0 0 24 24\" width=\"24\" height=\"24\"><path fill-rule=\"evenodd\" d=\"m12 24c-6.6 0-12-5.4-12-12 0-6.6 5.4-12 12-12 6.6 0 12 5.4 12 12 0 6.6-5.4 12-12 12zm10.6-12c0-5.9-4.7-10.6-10.6-10.6-5.9 0-10.6 4.7-10.6 10.6 0 5.9 4.7 10.6 10.6 10.6 5.9 0 10.6-4.7 10.6-10.6z\"><\/path><path d=\"m5.6 11.3h12.8v1.4h-12.8z\"><\/path><\/svg> <\/div><\/div><\/div><div class=\"esab__body\">\n<p class=\"wp-block-paragraph\">corrig\u00e9 \u00e0 venir<\/p>\n<\/div><\/div>\n<\/div><\/div>\n\n\n\n<p class=\"has-black-color has-text-color has-background has-link-color wp-elements-dee36af05feb399c1ebafcb663bf31be wp-block-paragraph\" style=\"background:linear-gradient(135deg,rgb(216,244,179) 0%,rgb(17,184,81) 100%)\">5<strong>) Exercices d&rsquo;entrainement<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/capytale2.ac-paris.fr\/web\/c\/e0c6-3919728\">https:\/\/capytale2.ac-paris.fr\/web\/c\/e0c6-3919728<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/yb-isn.fr\/2024\/nsi\/wp-content\/uploads\/2024\/08\/image-6-1024x490.png\" alt=\"\" class=\"wp-image-131\" style=\"width:322px;height:auto\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>corrig\u00e9s des exercices d&rsquo;entrainement https:\/\/capytale2.ac-paris.fr\/web\/c\/f134-3919478 Corrig\u00e9s des exercices euro dollar https:\/\/capytale2.ac-paris.fr\/web\/c\/c8b6-1874602<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-36","post","type-post","status-publish","format-standard","hentry","category-non-classe"],"_links":{"self":[{"href":"https:\/\/yb-isn.fr\/2025\/nsi\/wp-json\/wp\/v2\/posts\/36","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yb-isn.fr\/2025\/nsi\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yb-isn.fr\/2025\/nsi\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yb-isn.fr\/2025\/nsi\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yb-isn.fr\/2025\/nsi\/wp-json\/wp\/v2\/comments?post=36"}],"version-history":[{"count":6,"href":"https:\/\/yb-isn.fr\/2025\/nsi\/wp-json\/wp\/v2\/posts\/36\/revisions"}],"predecessor-version":[{"id":58,"href":"https:\/\/yb-isn.fr\/2025\/nsi\/wp-json\/wp\/v2\/posts\/36\/revisions\/58"}],"wp:attachment":[{"href":"https:\/\/yb-isn.fr\/2025\/nsi\/wp-json\/wp\/v2\/media?parent=36"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yb-isn.fr\/2025\/nsi\/wp-json\/wp\/v2\/categories?post=36"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yb-isn.fr\/2025\/nsi\/wp-json\/wp\/v2\/tags?post=36"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}