{"id":1985,"date":"2023-11-22T22:58:24","date_gmt":"2023-11-22T21:58:24","guid":{"rendered":"http:\/\/localhost:8080\/maxblog\/?p=1985"},"modified":"2023-11-22T23:00:04","modified_gmt":"2023-11-22T22:00:04","slug":"utilisation-des-variables-et-des-instructions-elementaires","status":"publish","type":"post","link":"https:\/\/www.maxdecours.com\/maxblog\/utilisation-des-variables-et-des-instructions-elementaires\/","title":{"rendered":"Utilisation des variables et des instructions \u00e9l\u00e9mentaires"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"1985\" class=\"elementor elementor-1985\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-7d71a4a elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"7d71a4a\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-389cd7d\" data-id=\"389cd7d\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-a8169f1 elementor-widget elementor-widget-spacer\" data-id=\"a8169f1\" data-element_type=\"widget\" data-widget_type=\"spacer.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-spacer\">\n\t\t\t<div class=\"elementor-spacer-inner\"><\/div>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-7643655 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"7643655\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-f297427\" data-id=\"f297427\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-361d80f elementor-widget elementor-widget-heading\" data-id=\"361d80f\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<div class=\"elementor-heading-title elementor-size-xl\">Utilisation des variables et des instructions \u00e9l\u00e9mentaires<\/div>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-de06178 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"de06178\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-50 elementor-top-column elementor-element elementor-element-c8b729b\" data-id=\"c8b729b\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap\">\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t<div class=\"elementor-column elementor-col-50 elementor-top-column elementor-element elementor-element-1f07f28\" data-id=\"1f07f28\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap\">\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-b7c611b elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"b7c611b\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-9a7e2c2\" data-id=\"9a7e2c2\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-fffe349 nc-justify-text elementor-widget elementor-widget-text-editor\" data-id=\"fffe349\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.maxdecours.com\/maxblog\/utilisation-des-variables-et-des-instructions-elementaires\/#Introduction\" >Introduction<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.maxdecours.com\/maxblog\/utilisation-des-variables-et-des-instructions-elementaires\/#Cours\" >Cours<\/a><ul class='ez-toc-list-level-2' ><li class='ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.maxdecours.com\/maxblog\/utilisation-des-variables-et-des-instructions-elementaires\/#1_Commentaires_en_Python\" >1. Commentaires en Python<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.maxdecours.com\/maxblog\/utilisation-des-variables-et-des-instructions-elementaires\/#2_Variables_informatiques\" >2. Variables informatiques<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.maxdecours.com\/maxblog\/utilisation-des-variables-et-des-instructions-elementaires\/#3_Affectation\" >3. Affectation<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.maxdecours.com\/maxblog\/utilisation-des-variables-et-des-instructions-elementaires\/#4_Sequence_dinstructions\" >4. S\u00e9quence d\u2019instructions<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.maxdecours.com\/maxblog\/utilisation-des-variables-et-des-instructions-elementaires\/#5_Instruction_conditionnelle_et_indentation\" >5. Instruction conditionnelle et indentation<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.maxdecours.com\/maxblog\/utilisation-des-variables-et-des-instructions-elementaires\/#6_Boucles\" >6. Boucles<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.maxdecours.com\/maxblog\/utilisation-des-variables-et-des-instructions-elementaires\/#Methodes\" >M\u00e9thodes<\/a><ul class='ez-toc-list-level-2' ><li class='ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.maxdecours.com\/maxblog\/utilisation-des-variables-et-des-instructions-elementaires\/#1_Choisir_ou_determiner_le_type_dune_variable\" >1. Choisir ou d\u00e9terminer le type d&rsquo;une variable<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/www.maxdecours.com\/maxblog\/utilisation-des-variables-et-des-instructions-elementaires\/#2_Concevoir_et_ecrire_une_instruction_daffectation_une_sequence_dinstructions_une_instruction_conditionnelle\" >2. Concevoir et \u00e9crire une instruction d&rsquo;affectation, une s\u00e9quence d&rsquo;instructions, une instruction conditionnelle<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/www.maxdecours.com\/maxblog\/utilisation-des-variables-et-des-instructions-elementaires\/#3_Ecrire_une_formule_permettant_un_calcul_combinant_des_variables\" >3. \u00c9crire une formule permettant un calcul combinant des variables<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/www.maxdecours.com\/maxblog\/utilisation-des-variables-et-des-instructions-elementaires\/#4_Programmer_une_boucle_bornee_et_une_boucle_non_bornee\" >4. Programmer une boucle born\u00e9e et une boucle non born\u00e9e<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/www.maxdecours.com\/maxblog\/utilisation-des-variables-et-des-instructions-elementaires\/#5_Dans_des_cas_plus_complexes_lire_comprendre_modifier_ou_completer_un_algorithme_ou_un_programme\" >5. Dans des cas plus complexes : lire, comprendre, modifier ou compl\u00e9ter un algorithme ou un programme<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h1><span class=\"ez-toc-section\" id=\"Introduction\"><\/span>Introduction<span class=\"ez-toc-section-end\"><\/span><\/h1><p class=\"MsoNormal\">\u00a0<\/p><p class=\"MsoNormal\">Ces concepts de base de Python sont essentiels pour comprendre et construire des programmes. La ma\u00eetrise des variables, des instructions \u00e9l\u00e9mentaires, et des structures de contr\u00f4le comme les boucles et les conditionnelles est la premi\u00e8re \u00e9tape pour devenir un bon programmeur en Python.<\/p><p class=\"MsoNormal\">\u00a0<\/p><h1><span class=\"ez-toc-section\" id=\"Cours\"><\/span>Cours<span class=\"ez-toc-section-end\"><\/span><\/h1><p class=\"MsoNormal\">\u00a0<\/p><h2><span class=\"ez-toc-section\" id=\"1_Commentaires_en_Python\"><\/span>1. Commentaires en Python<span class=\"ez-toc-section-end\"><\/span><\/h2><p class=\"MsoNormal\">\u00a0<\/p><p class=\"MsoNormal\">Avant de commencer, il est important de comprendre ce qu&rsquo;est un commentaire en programmation. Dans un script Python, tout texte qui suit le caract\u00e8re `#` sur une ligne est un commentaire. Les commentaires sont des notes ajout\u00e9es par le programmeur pour expliquer le code. Ils ne sont pas interpr\u00e9t\u00e9s par Python et n&rsquo;ont donc aucun effet sur le r\u00e9sultat du programme.<\/p><p class=\"MsoNormal\">\u00a0<\/p><p class=\"MsoNormal\"><b>Exemple :<\/b><\/p><pre style=\"line-height: 125%;\"><i><span style=\"font-size: 10.5pt; line-height: 125%; color: #408080;\"># Ceci est un commentaire et ne sera pas ex\u00e9cut\u00e9<\/span><\/i><\/pre><pre style=\"line-height: 125%;\"><b><span style=\"font-size: 10.5pt; line-height: 125%; color: green;\">print<\/span><\/b><span style=\"font-size: 10.5pt; line-height: 125%;\">(<span style=\"color: #ba2121;\">\"Bonjour !\"<\/span>)<span style=\"mso-spacerun: yes;\">\u00a0 <\/span><i><span style=\"color: #408080;\"># Ceci est aussi un commentaire<\/span><\/i><\/span><\/pre><p class=\"MsoNormal\">Dans cet exemple, seule la fonction print() sera ex\u00e9cut\u00e9e et affichera \u00ab\u00a0Bonjour !\u00a0\u00bb.<\/p><p class=\"MsoNormal\">\u00a0<\/p><h2><span class=\"ez-toc-section\" id=\"2_Variables_informatiques\"><\/span>2. Variables informatiques<span class=\"ez-toc-section-end\"><\/span><\/h2><p class=\"MsoNormal\">\u00a0<\/p><p class=\"MsoNormal\">En Python, une variable est une zone de la m\u00e9moire de l&rsquo;ordinateur o\u00f9 l&rsquo;on peut stocker une valeur. Cette valeur peut \u00eatre de diff\u00e9rents types :<\/p><p class=\"MsoNormal\">\u00a0<\/p><p class=\"MsoNormal\"><b>a. Entier (\u2018int\u2019)\u00a0:<\/b><\/p><p class=\"MsoNormal\">Les entiers sont des nombres sans d\u00e9cimales.<\/p><p class=\"MsoNormal\" style=\"line-height: 125%; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;\"><span style=\"font-size: 10.5pt; line-height: 125%; font-family: 'Courier New'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: FR;\">age <span style=\"color: #666666;\">=<\/span> <span style=\"color: #666666;\">25<\/span><span style=\"mso-spacerun: yes;\">\u00a0 <\/span><i><span style=\"color: #408080;\"># Un entier<\/span><\/i><\/span><\/p><p class=\"MsoNormal\">\u00a0<\/p><p class=\"MsoNormal\"><b>b. Bool\u00e9en (\u2018bool\u2019) :<\/b><\/p><p class=\"MsoNormal\">Un bool\u00e9en ne peut prendre que deux valeurs : \u2018True\u2019 ou \u2018False\u2019.<\/p><pre style=\"line-height: 125%;\"><span style=\"font-size: 10.5pt; line-height: 125%;\">est_majeur <span style=\"color: #666666;\">=<\/span> <span style=\"color: green;\">True<\/span><span style=\"mso-spacerun: yes;\">\u00a0 <\/span><i><span style=\"color: #408080;\"># Un bool\u00e9en<\/span><\/i><\/span><\/pre><p class=\"MsoNormal\">\u00a0<\/p><p class=\"MsoNormal\"><b>c. Flottant (\u2018float\u2019) :<\/b><\/p><p class=\"MsoNormal\">Les flottants sont des nombres \u00e0 virgule flottante (nombres d\u00e9cimaux).<\/p><pre style=\"line-height: 125%;\"><span style=\"font-size: 10.5pt; line-height: 125%;\">prix <span style=\"color: #666666;\">=<\/span> <span style=\"color: #666666;\">19.99<\/span><span style=\"mso-spacerun: yes;\">\u00a0 <\/span><i><span style=\"color: #408080;\"># Un flottant<\/span><\/i><\/span><\/pre><p class=\"MsoNormal\">\u00a0<\/p><p class=\"MsoNormal\"><b>d. Cha\u00eene de caract\u00e8res (\u2018str\u2019) :<\/b><\/p><p class=\"MsoNormal\">Les cha\u00eenes de caract\u00e8res sont des suites de lettres, chiffres ou symboles.<\/p><pre style=\"line-height: 125%;\"><span style=\"font-size: 10.5pt; line-height: 125%;\">nom <span style=\"color: #666666;\">=<\/span> <span style=\"color: #ba2121;\">\"Alice\"<\/span><span style=\"mso-spacerun: yes;\">\u00a0 <\/span><i><span style=\"color: #408080;\"># Une cha\u00eene de caract\u00e8res<\/span><\/i><\/span><\/pre><p class=\"MsoNormal\">\u00a0<\/p><h2><span class=\"ez-toc-section\" id=\"3_Affectation\"><\/span>3. Affectation<span class=\"ez-toc-section-end\"><\/span><\/h2><p class=\"MsoNormal\">\u00a0<\/p><p class=\"MsoNormal\">L&rsquo;affectation est l&rsquo;action d&rsquo;assigner une valeur \u00e0 une variable. En langage naturel, on note cela par \u2190. En Python, on utilise le signe \u2018=\u2018.<\/p><p class=\"MsoNormal\"><span style=\"font-size: 11.0pt;\">x \u2190 10 (En langage naturel)<\/span><\/p><p class=\"MsoNormal\"><span style=\"font-size: 11.0pt;\">\u00a0<\/span><\/p><pre style=\"line-height: 125%;\"><span style=\"font-size: 10.5pt; line-height: 125%;\">x <span style=\"color: #666666;\">=<\/span> <span style=\"color: #666666;\">10<\/span><span style=\"mso-spacerun: yes;\">\u00a0 <\/span><i><span style=\"color: #408080;\"># En Python<\/span><\/i><\/span><\/pre><p class=\"MsoNormal\">\u00a0<\/p><h2><span class=\"ez-toc-section\" id=\"4_Sequence_dinstructions\"><\/span>4. S\u00e9quence d\u2019instructions<span class=\"ez-toc-section-end\"><\/span><\/h2><p class=\"MsoNormal\">\u00a0<\/p><p class=\"MsoNormal\">Une s\u00e9quence d&rsquo;instructions est une suite d&rsquo;actions ex\u00e9cut\u00e9es les unes apr\u00e8s les autres.<\/p><pre style=\"line-height: 125%;\"><span style=\"font-size: 10.5pt; line-height: 125%;\">x <span style=\"color: #666666;\">=<\/span> <span style=\"color: #666666;\">10<\/span><span style=\"mso-spacerun: yes;\">\u00a0 <\/span><i><span style=\"color: #408080;\"># Affectation<\/span><\/i><\/span><\/pre><pre style=\"line-height: 125%;\"><span style=\"font-size: 10.5pt; line-height: 125%;\">y <span style=\"color: #666666;\">=<\/span> x <span style=\"color: #666666;\">+<\/span> <span style=\"color: #666666;\">5<\/span><span style=\"mso-spacerun: yes;\">\u00a0 <\/span><i><span style=\"color: #408080;\"># Op\u00e9ration<\/span><\/i><\/span><\/pre><pre style=\"line-height: 125%;\"><b><span style=\"font-size: 10.5pt; line-height: 125%; color: green;\">print<\/span><\/b><span style=\"font-size: 10.5pt; line-height: 125%;\">(y)<span style=\"mso-spacerun: yes;\">\u00a0 <\/span><i><span style=\"color: #408080;\"># Affichage : 15<\/span><\/i><\/span><\/pre><p class=\"MsoNormal\">\u00a0<\/p><h2><span class=\"ez-toc-section\" id=\"5_Instruction_conditionnelle_et_indentation\"><\/span>5. Instruction conditionnelle et indentation<span class=\"ez-toc-section-end\"><\/span><\/h2><p class=\"MsoNormal\">\u00a0<\/p><p class=\"MsoNormal\">L&rsquo;instruction conditionnelle permet d&rsquo;ex\u00e9cuter une instruction ou une s\u00e9quence d&rsquo;instructions seulement si une condition est remplie. Elle fait usage des mots-cl\u00e9s \u2018if\u2019 (qui signifie \u2018si\u2019 en anglais) et \u2018else\u2019 (\u2018sinon\u2019 en anglais). L&rsquo;utilisation du deux-points (\u2018:\u2019) et l\u2019indentation sont cruciales dans ce contexte, car elles indiquent \u00e0 Python quelles instructions appartiennent au bloc conditionnel.<\/p><p class=\"MsoNormal\">\u00a0<\/p><p class=\"MsoNormal\"><b>a. Deux-points :<\/b><\/p><p class=\"MsoNormal\">Le deux-points est utilis\u00e9 pour introduire un bloc de code. Apr\u00e8s un \u2018:\u2019, toutes les instructions indent\u00e9es qui suivent sont consid\u00e9r\u00e9es comme faisant partie du m\u00eame bloc.<\/p><p class=\"MsoNormal\">\u00a0<\/p><p class=\"MsoNormal\"><b>b. Indentation :<\/b><\/p><p class=\"MsoNormal\">En Python, l&rsquo;indentation (l&rsquo;espace avant une instruction) est utilis\u00e9e pour d\u00e9limiter un bloc de code. G\u00e9n\u00e9ralement, une indentation est r\u00e9alis\u00e9e avec une tabulation (un grand espace que l\u2019on peut cr\u00e9er en utilisant la touche du clavier pr\u00e9sentant une ou deux fl\u00e8ches horizontales, \u00e0 gauche de la touche [A], tout \u00e0 gauche du clavier) ou quatre espaces.<\/p><p class=\"MsoNormal\">\u00a0<\/p><p class=\"MsoNormal\">\u00a0<\/p><p class=\"MsoNormal\"><b>b. Exemple avec l&rsquo;instruction conditionnelle :<\/b><\/p><pre style=\"line-height: 125%;\"><span lang=\"EN-US\" style=\"font-size: 10.5pt; line-height: 125%; mso-ansi-language: EN-US;\">age <span style=\"color: #666666;\">=<\/span> <span style=\"color: #666666;\">20<\/span><\/span><\/pre><pre style=\"line-height: 125%;\"><b><span lang=\"EN-US\" style=\"font-size: 10.5pt; line-height: 125%; color: green; mso-ansi-language: EN-US;\">if<\/span><\/b><span lang=\"EN-US\" style=\"font-size: 10.5pt; line-height: 125%; mso-ansi-language: EN-US;\"> age <span style=\"color: #666666;\">&gt;=<\/span> <span style=\"color: #666666;\">18<\/span>:<\/span><\/pre><pre style=\"line-height: 125%;\"><span style=\"font-size: 10.5pt; line-height: 125%;\"><span style=\"mso-spacerun: yes;\">\u00a0\u00a0\u00a0 <\/span><b><span style=\"color: green;\">print<\/span><\/b>(<span style=\"color: #ba2121;\">\"Majeur\"<\/span>)<span style=\"mso-spacerun: yes;\">\u00a0 <\/span><i><span style=\"color: #408080;\"># Instruction ex\u00e9cut\u00e9e si la condition est vraie<\/span><\/i><\/span><\/pre><pre style=\"line-height: 125%;\"><b><span style=\"font-size: 10.5pt; line-height: 125%; color: green;\">else<\/span><\/b><span style=\"font-size: 10.5pt; line-height: 125%;\">:<\/span><\/pre><pre style=\"line-height: 125%;\"><span style=\"font-size: 10.5pt; line-height: 125%;\"><span style=\"mso-spacerun: yes;\">\u00a0\u00a0\u00a0 <\/span><b><span style=\"color: green;\">print<\/span><\/b>(<span style=\"color: #ba2121;\">\"Mineur\"<\/span>)<span style=\"mso-spacerun: yes;\">\u00a0 <\/span><i><span style=\"color: #408080;\"># Instruction ex\u00e9cut\u00e9e si la condition est fausse<\/span><\/i><\/span><\/pre><p class=\"MsoNormal\">\u00a0<\/p><p class=\"MsoNormal\">Dans cet exemple, les instructions \u2018print(\u00ab\u00a0Majeur\u00a0\u00bb)\u2019 et \u2018print(\u00ab\u00a0Mineur\u00a0\u00bb)\u2019 sont indent\u00e9es, indiquant qu&rsquo;elles sont \u00e0 l&rsquo;int\u00e9rieur des blocs \u2018if\u2019 et \u2018else\u2019, respectivement.<\/p><p class=\"MsoNormal\">\u00a0<\/p><p class=\"MsoNormal\"><b>c. Importance de l&rsquo;indentation :<\/b><\/p><p class=\"MsoNormal\">Si vous ne respectez pas l&rsquo;indentation, vous obtiendrez une erreur de syntaxe ou un comportement inattendu du programme.<\/p><pre style=\"line-height: 125%;\"><i><span style=\"font-size: 10.5pt; line-height: 125%; color: #408080;\"># Exemple incorrect<\/span><\/i><\/pre><pre style=\"line-height: 125%;\"><b><span style=\"font-size: 10.5pt; line-height: 125%; color: green;\">if<\/span><\/b><span style=\"font-size: 10.5pt; line-height: 125%;\"> age <span style=\"color: #666666;\">&gt;=<\/span> <span style=\"color: #666666;\">18<\/span>:<\/span><\/pre><pre style=\"line-height: 125%;\"><b><span style=\"font-size: 10.5pt; line-height: 125%; color: green;\">print<\/span><\/b><span style=\"font-size: 10.5pt; line-height: 125%;\">(<span style=\"color: #ba2121;\">\"Majeur\"<\/span>)<span style=\"mso-spacerun: yes;\">\u00a0 <\/span><i><span style=\"color: #408080;\"># Erreur ! Cette ligne doit \u00eatre indent\u00e9e<\/span><\/i><\/span><\/pre><pre style=\"line-height: 125%;\"><span style=\"font-size: 10.5pt; line-height: 125%;\">\u00a0<\/span><\/pre><pre style=\"line-height: 125%;\"><i><span lang=\"EN-US\" style=\"font-size: 10.5pt; line-height: 125%; color: #408080; mso-ansi-language: EN-US;\"># Exemple incorrect<\/span><\/i><\/pre><pre style=\"line-height: 125%;\"><b><span lang=\"EN-US\" style=\"font-size: 10.5pt; line-height: 125%; color: green; mso-ansi-language: EN-US;\">if<\/span><\/b><span lang=\"EN-US\" style=\"font-size: 10.5pt; line-height: 125%; mso-ansi-language: EN-US;\"> age <span style=\"color: #666666;\">&gt;=<\/span> <span style=\"color: #666666;\">18<\/span>:<\/span><\/pre><pre style=\"line-height: 125%;\"><span lang=\"EN-US\" style=\"font-size: 10.5pt; line-height: 125%; mso-ansi-language: EN-US;\"><span style=\"mso-spacerun: yes;\">\u00a0\u00a0\u00a0 <\/span><b><span style=\"color: green;\">print<\/span><\/b>(<span style=\"color: #ba2121;\">\"Majeur\"<\/span>)<\/span><\/pre><pre style=\"line-height: 125%;\"><b><span style=\"font-size: 10.5pt; line-height: 125%; color: green;\">print<\/span><\/b><span style=\"font-size: 10.5pt; line-height: 125%;\">(<span style=\"color: #ba2121;\">\"Bienvenue\"<\/span>)<span style=\"mso-spacerun: yes;\">\u00a0 <\/span><i><span style=\"color: #408080;\"># Cette ligne s'ex\u00e9cutera toujours, car elle n'est pas indent\u00e9e<\/span><\/i><\/span><\/pre><p class=\"MsoNormal\">\u00a0<\/p><h2><span class=\"ez-toc-section\" id=\"6_Boucles\"><\/span>6. Boucles<span class=\"ez-toc-section-end\"><\/span><\/h2><p class=\"MsoNormal\">\u00a0<\/p><p class=\"MsoNormal\"><b>a. Boucle born\u00e9e (\u2018for\u2019) :<\/b><\/p><p class=\"MsoNormal\">La boucle \u2018for\u2019 (qui signifie \u2018pour\u2019 en anglais) est utilis\u00e9e lorsque l&rsquo;on sait combien de fois on veut ex\u00e9cuter une instruction ou une s\u00e9quence d&rsquo;instructions.<\/p><p class=\"MsoNormal\">La fonction \u2018range(n)\u2019 (qui signifie \u2018s\u00e9rie\u2019 en anglais) g\u00e9n\u00e8re une s\u00e9quence de nombres allant de 0 \u00e0 <span class=\"katex-eq\" data-katex-display=\"false\"> n &#8211; 1 <\/span> (il y a donc n nombres). Lorsqu&rsquo;elle est utilis\u00e9e dans une boucle \u2018for\u2019, elle fait varier la variable \u2018i\u2019 \u00e0 travers cette s\u00e9quence.<\/p><p class=\"MsoNormal\">\u00a0<\/p><pre style=\"line-height: 125%;\"><b><span style=\"font-size: 10.5pt; line-height: 125%; color: green;\">for<\/span><\/b><span style=\"font-size: 10.5pt; line-height: 125%;\"> i <b><span style=\"color: #aa22ff;\">in<\/span><\/b> <span style=\"color: green;\">range<\/span>(<span style=\"color: #666666;\">5<\/span>):<span style=\"mso-spacerun: yes;\">\u00a0 <\/span><i><span style=\"color: #408080;\"># i prend les valeurs 0, 1, 2, 3 et 4 successivement<\/span><\/i><\/span><\/pre><pre style=\"line-height: 125%;\"><span style=\"font-size: 10.5pt; line-height: 125%;\"><span style=\"mso-spacerun: yes;\">\u00a0\u00a0\u00a0 <\/span><b><span style=\"color: green;\">print<\/span><\/b>(i)<span style=\"mso-spacerun: yes;\">\u00a0 <\/span><i><span style=\"color: #408080;\"># Affiche 0, 1, 2, 3, puis 4<\/span><\/i><\/span><\/pre><p class=\"MsoNormal\">\u00a0<\/p><p class=\"MsoNormal\"><b>b. Boucle non born\u00e9e (\u2018while\u2019) :<\/b><\/p><p class=\"MsoNormal\">La boucle \u2018while\u2019 (qui signifie \u2018tant que\u2019 en anglais) est utilis\u00e9e lorsqu&rsquo;on ne sait pas imm\u00e9diatement combien de fois on doit ex\u00e9cuter une instruction ou une s\u00e9quence d&rsquo;instructions. La boucle \u2018while\u2019 continue de r\u00e9p\u00e9ter son bloc d&rsquo;instructions tant que la condition sp\u00e9cifi\u00e9e est vraie.<\/p><p class=\"MsoNormal\">\u00a0<\/p><pre style=\"line-height: 125%;\"><span style=\"font-size: 10.5pt; line-height: 125%;\">x <span style=\"color: #666666;\">=<\/span> <span style=\"color: #666666;\">0<\/span><\/span><\/pre><pre style=\"line-height: 125%;\"><b><span style=\"font-size: 10.5pt; line-height: 125%; color: green;\">while<\/span><\/b><span style=\"font-size: 10.5pt; line-height: 125%;\"> x <span style=\"color: #666666;\">&lt;<\/span> <span style=\"color: #666666;\">5<\/span>:<span style=\"mso-spacerun: yes;\">\u00a0 <\/span><i><span style=\"color: #408080;\"># La boucle se r\u00e9p\u00e8te tant que x est inf\u00e9rieur \u00e0 5<\/span><\/i><\/span><\/pre><pre style=\"line-height: 125%;\"><span style=\"font-size: 10.5pt; line-height: 125%;\"><span style=\"mso-spacerun: yes;\">\u00a0\u00a0\u00a0 <\/span><b><span style=\"color: green;\">print<\/span><\/b>(x)<span style=\"mso-spacerun: yes;\">\u00a0 <\/span><i><span style=\"color: #408080;\"># Affiche 0, 1, 2, 3, puis 4<\/span><\/i><\/span><\/pre><pre style=\"line-height: 125%;\"><span style=\"font-size: 10.5pt; line-height: 125%;\"><span style=\"mso-spacerun: yes;\">\u00a0\u00a0\u00a0 <\/span>x <span style=\"color: #666666;\">+=<\/span> <span style=\"color: #666666;\">1<\/span><span style=\"mso-spacerun: yes;\">\u00a0 <\/span><i><span style=\"color: #408080;\"># Incr\u00e9mentation<\/span><\/i><\/span><\/pre><p class=\"MsoNormal\">\u00a0<\/p><h1><span class=\"ez-toc-section\" id=\"Methodes\"><\/span>M\u00e9thodes<span class=\"ez-toc-section-end\"><\/span><\/h1><p class=\"MsoNormal\">\u00a0<\/p><h2><span class=\"ez-toc-section\" id=\"1_Choisir_ou_determiner_le_type_dune_variable\"><\/span>1. Choisir ou d\u00e9terminer le type d&rsquo;une variable<span class=\"ez-toc-section-end\"><\/span><\/h2><p class=\"MsoNormal\">\u00a0<\/p><p class=\"MsoNormal\">Pour choisir le type d&rsquo;une variable, vous devez comprendre la nature des donn\u00e9es que vous souhaitez stocker. En Python, vous pouvez d\u00e9terminer le type d&rsquo;une variable existante \u00e0 l&rsquo;aide de la fonction \u2018type()\u2019.<\/p><p class=\"MsoNormal\">\u00a0<\/p><pre style=\"line-height: 125%;\"><span style=\"font-size: 10.5pt; line-height: 125%;\">x <span style=\"color: #666666;\">=<\/span> <span style=\"color: #666666;\">10<\/span><\/span><\/pre><pre style=\"line-height: 125%;\"><b><span style=\"font-size: 10.5pt; line-height: 125%; color: green;\">print<\/span><\/b><span style=\"font-size: 10.5pt; line-height: 125%;\">(<span style=\"color: green;\">type<\/span>(x))<span style=\"mso-spacerun: yes;\">\u00a0 <\/span><i><span style=\"color: #408080;\"># Affiche &lt;class 'int'&gt;<\/span><\/i><\/span><\/pre><p class=\"MsoNormal\">\u00a0<\/p><h2><span class=\"ez-toc-section\" id=\"2_Concevoir_et_ecrire_une_instruction_daffectation_une_sequence_dinstructions_une_instruction_conditionnelle\"><\/span>2. Concevoir et \u00e9crire une instruction d&rsquo;affectation, une s\u00e9quence d&rsquo;instructions, une instruction conditionnelle<span class=\"ez-toc-section-end\"><\/span><\/h2><p class=\"MsoNormal\">\u00a0<\/p><p class=\"MsoNormal\">&#8211; <b>Affectation<\/b> : Assigner une valeur \u00e0 une variable.<\/p><pre style=\"line-height: 125%;\"><span style=\"font-size: 10.5pt; line-height: 125%;\">x <span style=\"color: #666666;\">=<\/span> <span style=\"color: #666666;\">5<\/span><span style=\"mso-spacerun: yes;\">\u00a0 <\/span><i><span style=\"color: #408080;\"># Affectation d'un entier<\/span><\/i><\/span><\/pre><pre style=\"line-height: 125%;\"><span style=\"font-size: 10.5pt; line-height: 125%;\">y <span style=\"color: #666666;\">=<\/span> <span style=\"color: #666666;\">3.14<\/span><span style=\"mso-spacerun: yes;\">\u00a0 <\/span><i><span style=\"color: #408080;\"># Affectation d'un flottant<\/span><\/i><\/span><\/pre><pre style=\"line-height: 125%;\"><span style=\"font-size: 10.5pt; line-height: 125%;\">z <span style=\"color: #666666;\">=<\/span> <span style=\"color: #ba2121;\">\"Bonjour\"<\/span><span style=\"mso-spacerun: yes;\">\u00a0 <\/span><i><span style=\"color: #408080;\"># Affectation d'une cha\u00eene de caract\u00e8res<\/span><\/i><\/span><\/pre><p class=\"MsoNormal\">\u00a0<\/p><p class=\"MsoNormal\">&#8211; <b>S\u00e9quence d&rsquo;instructions<\/b> : Ex\u00e9cution d&rsquo;une suite d&rsquo;instructions l&rsquo;une apr\u00e8s l&rsquo;autre.<\/p><pre style=\"line-height: 125%;\"><span style=\"font-size: 10.5pt; line-height: 125%;\">x <span style=\"color: #666666;\">=<\/span> <span style=\"color: #666666;\">5<\/span><\/span><\/pre><pre style=\"line-height: 125%;\"><span style=\"font-size: 10.5pt; line-height: 125%;\">y <span style=\"color: #666666;\">=<\/span> x <span style=\"color: #666666;\">*<\/span> <span style=\"color: #666666;\">2<\/span><\/span><\/pre><pre style=\"line-height: 125%;\"><b><span style=\"font-size: 10.5pt; line-height: 125%; color: green;\">print<\/span><\/b><span style=\"font-size: 10.5pt; line-height: 125%;\">(y)<span style=\"mso-spacerun: yes;\">\u00a0 <\/span><i><span style=\"color: #408080;\"># Affiche 10<\/span><\/i><\/span><\/pre><p class=\"MsoNormal\">\u00a0<\/p><p class=\"MsoNormal\">&#8211; <b>Instruction conditionnelle<\/b> : Ex\u00e9cution conditionnelle d&rsquo;instructions.<\/p><pre style=\"line-height: 125%;\"><span lang=\"EN-US\" style=\"font-size: 10.5pt; line-height: 125%; mso-ansi-language: EN-US;\">age <span style=\"color: #666666;\">=<\/span> <span style=\"color: #666666;\">20<\/span><\/span><\/pre><pre style=\"line-height: 125%;\"><b><span lang=\"EN-US\" style=\"font-size: 10.5pt; line-height: 125%; color: green; mso-ansi-language: EN-US;\">if<\/span><\/b><span lang=\"EN-US\" style=\"font-size: 10.5pt; line-height: 125%; mso-ansi-language: EN-US;\"> age <span style=\"color: #666666;\">&gt;=<\/span> <span style=\"color: #666666;\">18<\/span>:<\/span><\/pre><pre style=\"line-height: 125%;\"><span lang=\"EN-US\" style=\"font-size: 10.5pt; line-height: 125%; mso-ansi-language: EN-US;\"><span style=\"mso-spacerun: yes;\">\u00a0\u00a0\u00a0 <\/span><b><span style=\"color: green;\">print<\/span><\/b>(<span style=\"color: #ba2121;\">\"Majeur\"<\/span>)<\/span><\/pre><pre style=\"line-height: 125%;\"><b><span style=\"font-size: 10.5pt; line-height: 125%; color: green;\">else<\/span><\/b><span style=\"font-size: 10.5pt; line-height: 125%;\">:<\/span><\/pre><pre style=\"line-height: 125%;\"><span style=\"font-size: 10.5pt; line-height: 125%;\"><span style=\"mso-spacerun: yes;\">\u00a0\u00a0\u00a0 <\/span><b><span style=\"color: green;\">print<\/span><\/b>(<span style=\"color: #ba2121;\">\"Mineur\"<\/span>)<\/span><\/pre><p class=\"MsoNormal\">\u00a0<\/p><h2><span class=\"ez-toc-section\" id=\"3_Ecrire_une_formule_permettant_un_calcul_combinant_des_variables\"><\/span>3. \u00c9crire une formule permettant un calcul combinant des variables<span class=\"ez-toc-section-end\"><\/span><\/h2><p class=\"MsoNormal\">\u00a0<\/p><p class=\"MsoNormal\">Vous pouvez combiner des variables de diff\u00e9rents types dans une expression ou une formule.<\/p><pre style=\"line-height: 125%;\"><span style=\"font-size: 10.5pt; line-height: 125%;\">prix_ht <span style=\"color: #666666;\">=<\/span> <span style=\"color: #666666;\">100<\/span><\/span><\/pre><pre style=\"line-height: 125%;\"><span style=\"font-size: 10.5pt; line-height: 125%;\">tva <span style=\"color: #666666;\">=<\/span> <span style=\"color: #666666;\">0.20<\/span><\/span><\/pre><pre style=\"line-height: 125%;\"><span style=\"font-size: 10.5pt; line-height: 125%;\">prix_ttc <span style=\"color: #666666;\">=<\/span> prix_ht <span style=\"color: #666666;\">*<\/span> (<span style=\"color: #666666;\">1<\/span> <span style=\"color: #666666;\">+<\/span> tva)<\/span><\/pre><pre style=\"line-height: 125%;\"><b><span style=\"font-size: 10.5pt; line-height: 125%; color: green;\">print<\/span><\/b><span style=\"font-size: 10.5pt; line-height: 125%;\">(prix_ttc)<span style=\"mso-spacerun: yes;\">\u00a0 <\/span><i><span style=\"color: #408080;\"># Affiche 120.0<\/span><\/i><\/span><\/pre><p class=\"MsoNormal\">\u00a0<\/p><h2><span class=\"ez-toc-section\" id=\"4_Programmer_une_boucle_bornee_et_une_boucle_non_bornee\"><\/span>4. Programmer une boucle born\u00e9e et une boucle non born\u00e9e<span class=\"ez-toc-section-end\"><\/span><\/h2><p class=\"MsoNormal\">\u00a0<\/p><p class=\"MsoNormal\"><span lang=\"EN-US\" style=\"mso-ansi-language: EN-US;\">&#8211; <b>Boucle born\u00e9e (\u2018for\u2019)<\/b> :<\/span><\/p><pre style=\"line-height: 125%;\"><b><span lang=\"EN-US\" style=\"font-size: 10.5pt; line-height: 125%; color: green; mso-ansi-language: EN-US;\">for<\/span><\/b><span lang=\"EN-US\" style=\"font-size: 10.5pt; line-height: 125%; mso-ansi-language: EN-US;\"> i <b><span style=\"color: #aa22ff;\">in<\/span><\/b> <span style=\"color: green;\">range<\/span>(<span style=\"color: #666666;\">5<\/span>):<\/span><\/pre><pre style=\"line-height: 125%;\"><span lang=\"EN-US\" style=\"font-size: 10.5pt; line-height: 125%; mso-ansi-language: EN-US;\"><span style=\"mso-spacerun: yes;\">\u00a0\u00a0\u00a0 <\/span><\/span><b><span style=\"font-size: 10.5pt; line-height: 125%; color: green;\">print<\/span><\/b><span style=\"font-size: 10.5pt; line-height: 125%;\">(i)<span style=\"mso-spacerun: yes;\">\u00a0 <\/span><i><span style=\"color: #408080;\"># Affiche les nombres de 0 \u00e0 4<\/span><\/i><\/span><\/pre><p class=\"MsoNormal\">\u00a0<\/p><p class=\"MsoNormal\"><span lang=\"EN-US\" style=\"mso-ansi-language: EN-US;\">&#8211; <b>Boucle non born\u00e9e (\u2018while\u2019)<\/b> :<\/span><\/p><pre style=\"line-height: 125%;\"><span lang=\"EN-US\" style=\"font-size: 10.5pt; line-height: 125%; mso-ansi-language: EN-US;\">x <span style=\"color: #666666;\">=<\/span> <span style=\"color: #666666;\">0<\/span><\/span><\/pre><pre style=\"line-height: 125%;\"><b><span lang=\"EN-US\" style=\"font-size: 10.5pt; line-height: 125%; color: green; mso-ansi-language: EN-US;\">while<\/span><\/b><span lang=\"EN-US\" style=\"font-size: 10.5pt; line-height: 125%; mso-ansi-language: EN-US;\"> x <span style=\"color: #666666;\">&lt;<\/span> <span style=\"color: #666666;\">5<\/span>:<\/span><\/pre><pre style=\"line-height: 125%;\"><span lang=\"EN-US\" style=\"font-size: 10.5pt; line-height: 125%; mso-ansi-language: EN-US;\"><span style=\"mso-spacerun: yes;\">\u00a0\u00a0\u00a0 <\/span><\/span><b><span style=\"font-size: 10.5pt; line-height: 125%; color: green;\">print<\/span><\/b><span style=\"font-size: 10.5pt; line-height: 125%;\">(x)<span style=\"mso-spacerun: yes;\">\u00a0 <\/span><i><span style=\"color: #408080;\"># Affiche les nombres de 0 \u00e0 4<\/span><\/i><\/span><\/pre><pre style=\"line-height: 125%;\"><span style=\"font-size: 10.5pt; line-height: 125%;\"><span style=\"mso-spacerun: yes;\">\u00a0\u00a0\u00a0 <\/span>x <span style=\"color: #666666;\">+=<\/span> <span style=\"color: #666666;\">1<\/span><\/span><\/pre><p class=\"MsoNormal\">\u00a0<\/p><h2><span class=\"ez-toc-section\" id=\"5_Dans_des_cas_plus_complexes_lire_comprendre_modifier_ou_completer_un_algorithme_ou_un_programme\"><\/span>5. Dans des cas plus complexes : lire, comprendre, modifier ou compl\u00e9ter un algorithme ou un programme<span class=\"ez-toc-section-end\"><\/span><\/h2><p class=\"MsoNormal\">\u00a0<\/p><p class=\"MsoNormal\">Pour aborder des programmes plus complexes, il faut pratiquer la lecture de code, comprendre la logique de l&rsquo;algorithme, et \u00eatre capable de le modifier ou de l&rsquo;am\u00e9liorer.<\/p><p class=\"MsoNormal\">\u00a0<\/p><p class=\"MsoNormal\"><b>Exemple :<\/b> Consid\u00e9rez l&rsquo;algorithme suivant qui trouve le plus grand nombre dans une liste.<\/p><pre style=\"line-height: 125%;\"><b><span style=\"font-size: 10.5pt; line-height: 125%; color: green;\">def<\/span><\/b><span style=\"font-size: 10.5pt; line-height: 125%;\"> <span style=\"color: blue;\">trouver_maximum<\/span>(liste):<\/span><\/pre><pre style=\"line-height: 125%;\"><span style=\"font-size: 10.5pt; line-height: 125%;\"><span style=\"mso-spacerun: yes;\">\u00a0\u00a0\u00a0 <\/span>maximum <span style=\"color: #666666;\">=<\/span> liste[<span style=\"color: #666666;\">0<\/span>]<\/span><\/pre><pre style=\"line-height: 125%;\"><span style=\"font-size: 10.5pt; line-height: 125%;\"><span style=\"mso-spacerun: yes;\">\u00a0\u00a0\u00a0 <\/span><b><span style=\"color: green;\">for<\/span><\/b> nombre <b><span style=\"color: #aa22ff;\">in<\/span><\/b> liste:<\/span><\/pre><pre style=\"line-height: 125%;\"><span style=\"font-size: 10.5pt; line-height: 125%;\"><span style=\"mso-spacerun: yes;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><b><span style=\"color: green;\">if<\/span><\/b> nombre <span style=\"color: #666666;\">&gt;<\/span> maximum:<\/span><\/pre><pre style=\"line-height: 125%;\"><span style=\"font-size: 10.5pt; line-height: 125%;\"><span style=\"mso-spacerun: yes;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span>maximum <span style=\"color: #666666;\">=<\/span> nombre<\/span><\/pre><pre style=\"line-height: 125%;\"><span style=\"font-size: 10.5pt; line-height: 125%;\"><span style=\"mso-spacerun: yes;\">\u00a0\u00a0\u00a0 <\/span><b><span style=\"color: green;\">return<\/span><\/b> maximum<\/span><\/pre><pre style=\"line-height: 125%;\"><span style=\"font-size: 10.5pt; line-height: 125%;\">\u00a0<\/span><\/pre><pre style=\"line-height: 125%;\"><i><span style=\"font-size: 10.5pt; line-height: 125%; color: #408080;\"># Utilisation<\/span><\/i><\/pre><pre style=\"line-height: 125%;\"><b><span style=\"font-size: 10.5pt; line-height: 125%; color: green;\">print<\/span><\/b><span style=\"font-size: 10.5pt; line-height: 125%;\">(trouver_maximum([<span style=\"color: #666666;\">1<\/span>, <span style=\"color: #666666;\">3<\/span>, <span style=\"color: #666666;\">7<\/span>, <span style=\"color: #666666;\">2<\/span>]))<span style=\"mso-spacerun: yes;\">\u00a0 <\/span><i><span style=\"color: #408080;\"># Affiche 7<\/span><\/i><\/span><\/pre><p class=\"MsoNormal\">\u00a0<\/p><p class=\"MsoNormal\">Pour le <b>modifier<\/b>, par exemple, afin de trouver le plus petit nombre, on peut changer la comparaison de \u2018nombre &gt; maximum\u2019 \u00e0 \u2018nombre &lt; minimum\u2019 et ajuster les noms des variables en cons\u00e9quence.<\/p><p class=\"MsoNormal\">\u00a0<\/p><p class=\"MsoNormal\">Pour le <b>compl\u00e9ter<\/b>, on pourrait ajouter des contr\u00f4les pour g\u00e9rer les cas o\u00f9 la liste est vide, etc.<\/p><p><style>@font-face\n\t{font-family:\"Cambria Math\";\n\tpanose-1:2 4 5 3 5 4 6 3 2 4;\n\tmso-font-charset:0;\n\tmso-generic-font-family:roman;\n\tmso-font-pitch:variable;\n\tmso-font-signature:-536870145 1107305727 0 0 415 0;}@font-face\n\t{font-family:Calibri;\n\tpanose-1:2 15 5 2 2 2 4 3 2 4;\n\tmso-font-charset:0;\n\tmso-generic-font-family:swiss;\n\tmso-font-pitch:variable;\n\tmso-font-signature:-536859905 -1073732485 9 0 511 0;}@font-face\n\t{font-family:\"Calibri Light\";\n\tpanose-1:2 15 3 2 2 2 4 3 2 4;\n\tmso-font-charset:0;\n\tmso-generic-font-family:swiss;\n\tmso-font-pitch:variable;\n\tmso-font-signature:-469750017 -1073732485 9 0 511 0;}p.MsoNormal, li.MsoNormal, div.MsoNormal\n\t{mso-style-unhide:no;\n\tmso-style-qformat:yes;\n\tmso-style-parent:\"\";\n\tmargin:0cm;\n\tmso-pagination:widow-orphan;\n\tfont-size:12.0pt;\n\tfont-family:\"Calibri\",sans-serif;\n\tmso-ascii-font-family:Calibri;\n\tmso-ascii-theme-font:minor-latin;\n\tmso-fareast-font-family:Calibri;\n\tmso-fareast-theme-font:minor-latin;\n\tmso-hansi-font-family:Calibri;\n\tmso-hansi-theme-font:minor-latin;\n\tmso-bidi-font-family:\"Times New Roman\";\n\tmso-bidi-theme-font:minor-bidi;\n\tmso-fareast-language:EN-US;}h1\n\t{mso-style-priority:9;\n\tmso-style-unhide:no;\n\tmso-style-qformat:yes;\n\tmso-style-link:\"Titre 1 Car\";\n\tmso-style-next:Normal;\n\tmargin-top:12.0pt;\n\tmargin-right:0cm;\n\tmargin-bottom:0cm;\n\tmargin-left:0cm;\n\tmso-pagination:widow-orphan lines-together;\n\tpage-break-after:avoid;\n\tmso-outline-level:1;\n\tfont-size:16.0pt;\n\tfont-family:\"Calibri Light\",sans-serif;\n\tmso-ascii-font-family:\"Calibri Light\";\n\tmso-ascii-theme-font:major-latin;\n\tmso-fareast-font-family:\"Times New Roman\";\n\tmso-fareast-theme-font:major-fareast;\n\tmso-hansi-font-family:\"Calibri Light\";\n\tmso-hansi-theme-font:major-latin;\n\tmso-bidi-font-family:\"Times New Roman\";\n\tmso-bidi-theme-font:major-bidi;\n\tcolor:#2F5496;\n\tmso-themecolor:accent1;\n\tmso-themeshade:191;\n\tmso-font-kerning:0pt;\n\tmso-fareast-language:EN-US;\n\tfont-weight:normal;}h2\n\t{mso-style-priority:9;\n\tmso-style-qformat:yes;\n\tmso-style-link:\"Titre 2 Car\";\n\tmso-style-next:Normal;\n\tmargin-top:2.0pt;\n\tmargin-right:0cm;\n\tmargin-bottom:0cm;\n\tmargin-left:0cm;\n\tmso-pagination:widow-orphan lines-together;\n\tpage-break-after:avoid;\n\tmso-outline-level:2;\n\tfont-size:13.0pt;\n\tfont-family:\"Calibri Light\",sans-serif;\n\tmso-ascii-font-family:\"Calibri Light\";\n\tmso-ascii-theme-font:major-latin;\n\tmso-fareast-font-family:\"Times New Roman\";\n\tmso-fareast-theme-font:major-fareast;\n\tmso-hansi-font-family:\"Calibri Light\";\n\tmso-hansi-theme-font:major-latin;\n\tmso-bidi-font-family:\"Times New Roman\";\n\tmso-bidi-theme-font:major-bidi;\n\tcolor:#2F5496;\n\tmso-themecolor:accent1;\n\tmso-themeshade:191;\n\tmso-fareast-language:EN-US;\n\tfont-weight:normal;}pre\n\t{mso-style-priority:99;\n\tmso-style-link:\"Pr\u00e9format\u00e9 HTML Car\";\n\tmargin:0cm;\n\tmargin-bottom:.0001pt;\n\tmso-pagination:widow-orphan;\n\tfont-size:10.0pt;\n\tfont-family:\"Courier New\";\n\tmso-fareast-font-family:\"Times New Roman\";}span.Titre1Car\n\t{mso-style-name:\"Titre 1 Car\";\n\tmso-style-priority:9;\n\tmso-style-unhide:no;\n\tmso-style-locked:yes;\n\tmso-style-link:\"Titre 1\";\n\tmso-ansi-font-size:16.0pt;\n\tmso-bidi-font-size:16.0pt;\n\tfont-family:\"Calibri Light\",sans-serif;\n\tmso-ascii-font-family:\"Calibri Light\";\n\tmso-ascii-theme-font:major-latin;\n\tmso-fareast-font-family:\"Times New Roman\";\n\tmso-fareast-theme-font:major-fareast;\n\tmso-hansi-font-family:\"Calibri Light\";\n\tmso-hansi-theme-font:major-latin;\n\tmso-bidi-font-family:\"Times New Roman\";\n\tmso-bidi-theme-font:major-bidi;\n\tcolor:#2F5496;\n\tmso-themecolor:accent1;\n\tmso-themeshade:191;}span.Titre2Car\n\t{mso-style-name:\"Titre 2 Car\";\n\tmso-style-priority:9;\n\tmso-style-unhide:no;\n\tmso-style-locked:yes;\n\tmso-style-link:\"Titre 2\";\n\tmso-ansi-font-size:13.0pt;\n\tmso-bidi-font-size:13.0pt;\n\tfont-family:\"Calibri Light\",sans-serif;\n\tmso-ascii-font-family:\"Calibri Light\";\n\tmso-ascii-theme-font:major-latin;\n\tmso-fareast-font-family:\"Times New Roman\";\n\tmso-fareast-theme-font:major-fareast;\n\tmso-hansi-font-family:\"Calibri Light\";\n\tmso-hansi-theme-font:major-latin;\n\tmso-bidi-font-family:\"Times New Roman\";\n\tmso-bidi-theme-font:major-bidi;\n\tcolor:#2F5496;\n\tmso-themecolor:accent1;\n\tmso-themeshade:191;}span.PrformatHTMLCar\n\t{mso-style-name:\"Pr\u00e9format\u00e9 HTML Car\";\n\tmso-style-priority:99;\n\tmso-style-unhide:no;\n\tmso-style-locked:yes;\n\tmso-style-link:\"Pr\u00e9format\u00e9 HTML\";\n\tmso-ansi-font-size:10.0pt;\n\tmso-bidi-font-size:10.0pt;\n\tfont-family:\"Courier New\";\n\tmso-ascii-font-family:\"Courier New\";\n\tmso-fareast-font-family:\"Times New Roman\";\n\tmso-hansi-font-family:\"Courier New\";\n\tmso-bidi-font-family:\"Courier New\";\n\tmso-fareast-language:FR;}.MsoChpDefault\n\t{mso-style-type:export-only;\n\tmso-default-props:yes;\n\tfont-family:\"Calibri\",sans-serif;\n\tmso-ascii-font-family:Calibri;\n\tmso-ascii-theme-font:minor-latin;\n\tmso-fareast-font-family:Calibri;\n\tmso-fareast-theme-font:minor-latin;\n\tmso-hansi-font-family:Calibri;\n\tmso-hansi-theme-font:minor-latin;\n\tmso-bidi-font-family:\"Times New Roman\";\n\tmso-bidi-theme-font:minor-bidi;\n\tmso-fareast-language:EN-US;}div.WordSection1\n\t{page:WordSection1;}<\/style><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-854e1d3 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"854e1d3\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-8392cf9\" data-id=\"8392cf9\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap\">\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-071e74f elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"071e74f\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-8c43dc4\" data-id=\"8c43dc4\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-aa0c527 elementor-widget elementor-widget-spacer\" data-id=\"aa0c527\" data-element_type=\"widget\" data-widget_type=\"spacer.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-spacer\">\n\t\t\t<div class=\"elementor-spacer-inner\"><\/div>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-3c0ad71 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"3c0ad71\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-a39de31\" data-id=\"a39de31\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-342de24 elementor-widget elementor-widget-spacer\" data-id=\"342de24\" data-element_type=\"widget\" data-widget_type=\"spacer.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-spacer\">\n\t\t\t<div class=\"elementor-spacer-inner\"><\/div>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>Utilisation des variables et des instructions \u00e9l\u00e9mentaires Introduction Ces concepts de base de Python sont essentiels pour comprendre et construire des programmes. La ma\u00eetrise des variables, des instructions \u00e9l\u00e9mentaires, et des structures de contr\u00f4le comme les boucles et les conditionnelles est la premi\u00e8re \u00e9tape pour devenir un bon programmeur en Python. Cours 1. Commentaires en [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"elementor_canvas","format":"standard","meta":{"footnotes":""},"categories":[25,26,5],"tags":[],"_links":{"self":[{"href":"https:\/\/www.maxdecours.com\/maxblog\/wp-json\/wp\/v2\/posts\/1985"}],"collection":[{"href":"https:\/\/www.maxdecours.com\/maxblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.maxdecours.com\/maxblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.maxdecours.com\/maxblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.maxdecours.com\/maxblog\/wp-json\/wp\/v2\/comments?post=1985"}],"version-history":[{"count":5,"href":"https:\/\/www.maxdecours.com\/maxblog\/wp-json\/wp\/v2\/posts\/1985\/revisions"}],"predecessor-version":[{"id":1990,"href":"https:\/\/www.maxdecours.com\/maxblog\/wp-json\/wp\/v2\/posts\/1985\/revisions\/1990"}],"wp:attachment":[{"href":"https:\/\/www.maxdecours.com\/maxblog\/wp-json\/wp\/v2\/media?parent=1985"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.maxdecours.com\/maxblog\/wp-json\/wp\/v2\/categories?post=1985"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.maxdecours.com\/maxblog\/wp-json\/wp\/v2\/tags?post=1985"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}