diff --git a/Notebooks/03_fonction_simple.ipynb b/Notebooks/03_fonction_simple.ipynb index 62ed92135dac1c99d2fb3bfb58374df6d81ddae7..d5950ef56b0481aa96101d85d0632777d8e259a0 100755 --- a/Notebooks/03_fonction_simple.ipynb +++ b/Notebooks/03_fonction_simple.ipynb @@ -1 +1 @@ -{"cells":[{"metadata":{},"cell_type":"markdown","source":"<div class = \"alert alert-danger\"> \n \nAttention: **veillez à bien sauvegarder votre travail** dans le bon dossier du disque réseau (dossier document) avec le bon nom (et l'extension *.ipynb*), **sinon toutes les modifications seront perdues!**\n\nPour reprendre votre travail, il suffit d'ouvrir le fichier .ipynb en cliquant sur *Fichier ouvrir*\n</div>"},{"metadata":{},"cell_type":"markdown","source":"# Le fonctions simples (brouillon)"},{"metadata":{},"cell_type":"markdown","source":"Rappel de quelques fonction de Turtle avec des exemples qui pourront vous servir\n\n| Fonction |Exemple|Commentaire|\n|:-------- |:------|:----------|\n|forward(x)|forward(150)|Trace un trait de 150 points|\n|backward(x)|backward(150)|Trace un trait “à reculons” de 150 points|\n|left(n)|left(60)|Tourne sur place la tortue de 60° à gauche|\n|right(n)|right(60)|Tourne sur place la tortue de 60° à droite|\n|width(x)|width(5)|Change l’épaisseur à 5 points|\n|color(\"c\")|color(\"yellow\")|Change la couleur du trait (mais aucun trait n’est tracé à ce moment). Notez les guillemets !|\n|penup()|penup()|Lève la tortue (permet de se déplacer sans dessiner)|\n|pendown()|pendown()|Baisse le stylo|\n|circle(R, A)|circle(100, 180)|Dessine un demi-cercle (angle de 180°) de rayon 100 points|\n|stamp()|stamp()|Laisse une impression de la tortue à sa position actuelle|\n|shape(forme)|shape('circle')|Change la forme de la tortue|"},{"metadata":{},"cell_type":"markdown","source":"# Définir - `def`\n\nDans ce chapitre, nous allons découvrir comment augmenter le vocabulaire de notre langage de programmation en définissant de nouvelles instructions, qu'on appelle aussi **fonction**. Ceci permet de rendre un code plus compact, mais surtout plus lisible. Nous allons voir que :\n\n- le mot-clé `def` permet de nommer (définir) une séquence,\n- le bloc qui suit doit être en **indentation** (décalé à droite),"},{"metadata":{},"cell_type":"markdown","source":"<h3 style=\"color:chocolate;background-color:papayawhip;\" > <i class=\"fa fa-question\" aria-hidden=\"true\"> </i> Quizz </h3> \n \n```\nUne fonction permet de\n\nA) donner un nom à une séquence\nB) augmenter le vocabulaire du langage de programmation\nC) nous dire si ça fonctionne\nD) rendre un programme plus lisible\n```"},{"metadata":{},"cell_type":"markdown","source":"<details>\n<summary style=\"border-left:3px solid #3c763d; border-radius:2pt; width:100%; color:#3c763d; padding:6px; background-color: #dff0d8\"> \nRéponse\n</summary> \n\n<div style=\"border-left:3px solid #3c763d; border-radius:2pt; color:#3c763d; padding:6px; background-color: #eff0e8\">\nA) donner un nom à une séquence\n\nB) augmenter le vocabulaire du langage de programmation\n\nD) rendre un programme plus lisible\n</div>\n</details>"},{"metadata":{},"cell_type":"markdown","source":"## Nommer une séquence\n\nDessiner un rectangle est assez utile. C'est une forme qu'on pourra réutiliser certainement souvent. Il serait pratique de définir un nom pour ces 8 lignes de code. Pouvons-nous définir de nouvelles commandes ?"},{"metadata":{"trusted":true},"cell_type":"code","source":"forward(160)\nleft(90)\nforward(100)\nleft(90)\nforward(160)\nleft(90)\nforward(100)\nleft(90)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Oui, c'est possible. Avec le mot-clé `def`, nous pouvons définir une nouvelle commande que nous pouvons par exemple appeler `rectangle()`.\nCette façon de créer un raccourci est appelée **définir** une fonction.\nLe code à exécuter suit l'expression `def rectangle():` et se trouve en **indentation** (décalé vers la droite).\n\nEnsuite, il suffit d'écrire `rectangle()` pour dessiner un rectangle. On appelle ceci **appeler** une fonction.\nRappelez-vous ceci :\n\n- on définit une fonction une seule fois,\n- on appelle une fonction autant de fois que l'on veut,\n- si on ne l'appelle pas, elle n'est pas exécutée et il ne se passe rien.\n\nDéfinir une fonction nous permet de réduire le nombre de lignes de code nécessaires.\nChaque fois que nous utilisons `rectangle()`,\nau lieu d'écrire 8 lignes, nous écrivons seulement une ligne de code."},{"metadata":{},"cell_type":"markdown","source":"<h3 style=\"color:teal;background-color:azure;\" > <i class=\"fa fa-pencil\" aria-hidden=\"true\"> </i> Exercice 1 </h3>\n\nDessinez encore d'autres rectangles en appelant la nouvelle fonction `rectangle()`.\n\n"},{"metadata":{"trusted":true},"cell_type":"code","source":"from turtle import *\n\ndef rectangle():\n forward(160)\n left(90)\n forward(100)\n left(90)\n forward(160)\n left(90)\n forward(100)\n left(90)\n\nrectangle()\nleft(90)\nrectangle()\n\ndone()\n","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<h3 style=\"color:chocolate;background-color:papayawhip;\" > <i class=\"fa fa-question\" aria-hidden=\"true\"> </i> Quizz </h3> \n \n```\nRappel: Une indentation de texte est\n\nA) un décalage vers la gauche\nB) un décalage vers la droite\nC) une mise en paragraphe\nD) une mise en sous-section\n```"},{"metadata":{},"cell_type":"markdown","source":"<details>\n<summary style=\"border-left:3px solid #3c763d; border-radius:2pt; width:100%; color:#3c763d; padding:6px; background-color: #dff0d8\"> \nRéponse\n</summary> \n\n<div style=\"border-left:3px solid #3c763d; border-radius:2pt; color:#3c763d; padding:6px; background-color: #eff0e8\">\nB) un décalage vers la droite\n</div>\n</details>"},{"metadata":{},"cell_type":"markdown","source":"## Donner du sens\n\nUne fonction ne permet pas seulement d'économiser des lignes de code.\nElle permet aussi de structurer le code et de lui donner un sens. Considérez par exemple le code ci-dessous. Il est presque impossible de comprendre ce que fait le programme en regardant les 17 lignes de code.\n\n"},{"metadata":{"trusted":true},"cell_type":"code","source":"from turtle import *\n\nforward(200)\nleft(90)\nforward(100)\nleft(90)\nforward(200)\nleft(90)\nforward(100)\nleft(90)\nforward(30)\nforward(30)\nleft(90)\nforward(50)\nleft(90)\nforward(30)\nleft(90)\nforward(50)\nleft(90)\n\ndone()\n","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Si nous observons la tortue, nous comprenons finalement qu'elle dessine deux fois un rectangle. Nous pouvons même interpréter cette image et donner le sens de bâtiment au premier rectangle, et de porte au second.\n\nEssayons maintenant de découper le code en **sous-programmes** en utilisant deux fonctions `batiment()` et `porte()`.\nEn regardant ces 3 lignes de code, on comprend immédiatement le sens du programme.\n\n``` python\nbatiment()\nforward(30) # repositionner la tortue\nporte()\n```\n\nLa définition d'une fonction permet d'ajouter de nouveaux mots à un langage de programmation. Contrairement aux commandes natives de Python qui sont toutes en anglais, nous sommes libres de les choisir en français.\n\n**Attention** : écrivez les fonctions sans accents et sans circonflexes : `batiment()`, `carre()`, `boite()`.\n\n"},{"metadata":{},"cell_type":"markdown","source":"<h3 style=\"color:teal;background-color:azure;\" > <i class=\"fa fa-pencil\" aria-hidden=\"true\"> </i> Exercice 2 </h3>Ajoutez une deuxième porte au bâtiment. Ensuite, faites-en une porte double.\n\n"},{"metadata":{"trusted":true},"cell_type":"code","source":"from turtle import *\n\ndef batiment():\n forward(200)\n left(90)\n forward(100)\n left(90)\n forward(200)\n left(90)\n forward(100)\n left(90)\n\ndef porte():\n forward(30)\n left(90)\n forward(50)\n left(90)\n forward(30)\n left(90)\n forward(50)\n left(90)\n\nbatiment()\nforward(30)\nporte()\n\ndone()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<h3 style=\"color:chocolate;background-color:papayawhip;\" > <i class=\"fa fa-question\" aria-hidden=\"true\"> </i> Quizz </h3> \n\nÀ combien de lignes de code la fonction `porte()` est-elle équivalente ?\n\n\n```\nA) 1 ligne\nB) 2 lignes\nC) 8 lignes\nD) 17 lignes\n```"},{"metadata":{},"cell_type":"markdown","source":"<details>\n<summary style=\"border-left:3px solid #3c763d; border-radius:2pt; width:100%; color:#3c763d; padding:6px; background-color: #dff0d8\"> \nRéponse\n</summary> \n\n<div style=\"border-left:3px solid #3c763d; border-radius:2pt; color:#3c763d; padding:6px; background-color: #eff0e8\">\nC) 8 lignes\n</div>\n</details>"},{"metadata":{},"cell_type":"markdown","source":"## Définir une fonction\n\nLe fait de donner un nom à une séquence d'instructions est appelé **définir une fonction**. Une **définition de fonction** comporte :\n\n1. le mot-clé `def` (définir),\n1. le nom de la fonction (`batiment/porte`),\n1. les parenthèses `()`,\n1. le deux-points `:`,\n1. un bloc en indentation.\n\nQu'est-ce qu'un bloc en indentation ?\nC'est un bloc de texte qui comporte des espaces vides à gauche. En Python, ces espaces apparaissent en multiples de 4.\n\nL'indentation est très importante en Python. C'est l'indentation qui indique l'étendue des instructions qui font partie de la fonction.\n\n"},{"metadata":{},"cell_type":"markdown","source":"<h3 style=\"color:chocolate;background-color:papayawhip;\" > <i class=\"fa fa-question\" aria-hidden=\"true\"> </i> Quizz </h3> \n \n```\nParmi les 4 définitions de fonction ci-dessous, laquelle est correcte ?\n\nA) def() rectangle:\nB) def: rectangle\nC) def rectangle():\nD) def(rectangle):\n```"},{"metadata":{},"cell_type":"markdown","source":"<details>\n<summary style=\"border-left:3px solid #3c763d; border-radius:2pt; width:100%; color:#3c763d; padding:6px; background-color: #dff0d8\"> \nRéponse\n</summary> \n\n<div style=\"border-left:3px solid #3c763d; border-radius:2pt; color:#3c763d; padding:6px; background-color: #eff0e8\">\nC) def rectangle():\n</div>\n</details>"},{"metadata":{},"cell_type":"markdown","source":"## Indenter avec un raccourci\n\nComme l'indentation est tellement importante en Python, il en existe un raccourci.\nIl faut d'abord sélectionner **les lignes** de code dont vous voulez changer l'indentation.\nEnsuite, vous appuyez sur :\n\n- la touche **tab** pour augmenter l'indentation\n- la touche **maj+tab** pour diminuer l'indentation\n\n"},{"metadata":{},"cell_type":"markdown","source":"<h3 style=\"color:teal;background-color:azure;\" > <i class=\"fa fa-pencil\" aria-hidden=\"true\"> </i> Exercice 3 </h3>Essayez ces raccourcis dans le code ci-dessous. Transformez le code en deux fonctions `batiment()` et `porte()`, que vous appelez ensuite.\n\n"},{"metadata":{"trusted":true},"cell_type":"code","source":"from turtle import *\n\nforward(200)\nleft(90)\nforward(100)\nleft(90)\nforward(200)\nleft(90)\nforward(100)\nleft(90)\nforward(30)\nforward(30)\nleft(90)\nforward(50)\nleft(90)\nforward(30)\nleft(90)\nforward(50)\nleft(90)\n\ndone()\n","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Voici encore un raccourci très utile : **maj(ou Shift)+Enter** pour exécuter le code.\n\n"},{"metadata":{},"cell_type":"markdown","source":"## Maison avec porte\n\nUne fois qu'une fonction est définie, elle peut être utilisée partout, même dans la définition d'une autre fonction.\n\nIci, nous avons une fonction `porte()`, qui est utilisée à l'intérieur d'une deuxième fonction `maison()`. Pour que ceci soit possible, la définition de porte doit être placée avant la définition de `maison()`.\n\n"},{"metadata":{},"cell_type":"markdown","source":"<h3 style=\"color:teal;background-color:azure;\" > <i class=\"fa fa-pencil\" aria-hidden=\"true\"> </i> Exercice 4 </h3>Déplacez la porte vers le milieu de la maison, et dessinez une deuxième maison à coté.\n\n"},{"metadata":{"trusted":true},"cell_type":"code","source":"from turtle import *\n\ndef porte():\n forward(20)\n left(90)\n forward(40)\n left(90)\n forward(20)\n left(90)\n forward(40)\n left(90)\n\ndef maison():\n forward(100)\n left(90)\n forward(60)\n left(45)\n forward(71)\n left(90)\n forward(71)\n left(45)\n forward(60)\n left(90)\n porte()\n\nmaison()\n\ndone()\n","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## Plus sur \"La tortue\"\n"},{"metadata":{},"cell_type":"markdown","source":"### Le point `dot()`\n\nLa fonction `dot()` dessine un point à la position actuelle de la tortue."},{"metadata":{},"cell_type":"markdown","source":"<h3 style=\"color:teal;background-color:azure;\" > <i class=\"fa fa-pencil\" aria-hidden=\"true\"> </i> Exercice 5 </h3>Ajoutez un point (`dot`) au sommet du triangle.\n\n"},{"metadata":{"trusted":true},"cell_type":"code","source":"from turtle import *\n\ndef triangle():\n dot()\n forward(100)\n left(120)\n dot()\n forward(100)\n left(120)\n forward(100)\n\ntriangle()\n\ndone()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"### Lever le stylo\n\nLes deux commandes `up()` et `down()` permettent de lever et de baisser le stylo.\nCeci nous permet de dessiner des formes séparées, comme ici le petit i avec son point.\n"},{"metadata":{},"cell_type":"markdown","source":"<h3 style=\"color:teal;background-color:azure;\" > <i class=\"fa fa-pencil\" aria-hidden=\"true\"> </i> Exercice 6 </h3>Transformez le i vers un i avec trema (deux points).\n"},{"metadata":{"trusted":true},"cell_type":"code","source":"from turtle import *\n\ndef i():\n dot()\n pendown() # poser le stylo\n left(90)\n forward(50)\n penup() # lever le stylo\n forward(50)\n dot()\n backward(2*50)\n right(90)\n forward(50/2) # avancer à la prochaine lettre\n\ni()\ni()\n\ndone()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## Exercices d'entraînement\n\n<h3 style=\"color:teal;background-color:azure;\" > <i class=\"fa fa-pencil\" aria-hidden=\"true\"> </i> Exercice 7 </h3>\n\nCompléter le programme ci-dessous en ajoutant des appels à la fonction `forme_mystere()` pour pour créer le dessin suivant:\n"},{"metadata":{"trusted":true},"cell_type":"code","source":"# permet d'utiliser les fonctions pour dessiner\nfrom turtle import *\n\n# Définition de la fonction mystère\ndef forme_mystere():\n for k in range(4):\n forward(100)\n right(90)\n\n\nforme_mystere()\n# à compléter \n\ndone()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<h3 style=\"color:teal;background-color:azure;\" > <i class=\"fa fa-pencil\" aria-hidden=\"true\"> </i> Exercice 8 </h3>\n\n1. Testez le programme suivant."},{"metadata":{"trusted":true},"cell_type":"code","source":"# permet d'utiliser les fonctions pour dessiner\nfrom turtle import *\n\n# Code à factoriser\nfor k in range(6):\n forward(200)\n right(60)\nright(60)\nfor k in range(6):\n forward(200)\n right(60)\nright(60)\nfor k in range(6):\n forward(200)\n right(60)\nright(60)\nfor k in range(6):\n forward(200)\n right(60)\nright(60)\nfor k in range(6):\n forward(200)\n right(60)\nright(60)\nfor k in range(6):\n forward(200)\n right(60)\nright(60)\n\ndone()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"2. Définissez une fonction `hexagone()` qui permet de tracer des hexagones et utilisez-là pour réduire le nombre d’instructions du programme précédent."},{"metadata":{},"cell_type":"markdown","source":""},{"metadata":{},"cell_type":"markdown","source":"<h3 style=\"color:teal;background-color:azure;\" > <i class=\"fa fa-pencil\" aria-hidden=\"true\"> </i> Exercice 9 </h3>\n\nTestez le programme ci-dessous, puis modifiez le en définissant au début une fonction `carre100()` qui dessine un carré de longueur 100 afin d'obtenir un programme structuré sans répétition inutile."},{"metadata":{"trusted":true},"cell_type":"code","source":"from turtle import *\n\n\nfor _ in range(4):\n forward(100)\n left(90)\n\n\nleft(180)\n\n\nfor _ in range(4):\n forward(100)\n left(90)\n\ndone()\n","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<h3 style=\"color:teal;background-color:azure;\" > <i class=\"fa fa-pencil\" aria-hidden=\"true\"> </i> Exercice 10 </h3>\nDans le programme ci-dessous:\n\n1. Définissez une fonction `triangle100()` pour dessiner un triangle équilatéral de côté 100 comme dans l’illustration A.\n \n2. Utilisez `triangle100()` pour dessiner une forme comme dans l’illustration B.\n\n"},{"metadata":{"trusted":true},"cell_type":"code","source":"from turtle import *\n\n# à compléter\n\ndone()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<h3 style=\"color:teal;background-color:azure;\" > <i class=\"fa fa-pencil\" aria-hidden=\"true\"> </i> Exercice 11 </h3>\n\nUtilisez les commandes `carre100()` et `triangle100()` définies dans les exercices 9 et 10 pour dessiner une figure semblable à celle représentée ci-dessous.\n"},{"metadata":{"trusted":true},"cell_type":"code","source":"from turtle import *\n\n# à compléter\n\ndone()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<h3 style=\"color:teal;background-color:azure;\" > <i class=\"fa fa-pencil\" aria-hidden=\"true\"> </i> Exercice 12 </h3>\n\nDans le programme ci-dessous:\n\n1. Définissez une fonction `carre_ouvert()` qui dessine un carré ouvert comme dans l’illustration A.\n\n \n2. Utilisez `triangle100()` pour dessiner une croix comme dans l’illustration B.\n\n"},{"metadata":{"trusted":false},"cell_type":"code","source":"from turtle import *\n\n# à compléter\n\ndone()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<h3 style=\"color:teal;background-color:azure;\" > <i class=\"fa fa-pencil\" aria-hidden=\"true\"> </i> Exercice 9 </h3>\n\nCréez une fonction `paquebot()` et utilisez pour dessiner deux paquebots."},{"metadata":{"trusted":true},"cell_type":"code","source":"from turtle import *\n\nforward(200)\nleft(80)\nforward(60)\nleft(100)\nforward(220)\nleft(100)\nforward(60)\n\npenup()\nleft(125)\nforward(30)\nright(45)\n\nfor i in range(6):\n pendown()\n circle(10, 360)\n penup()\n forward(30)\n \n\ndone()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<h3 style=\"color:teal;background-color:azure;\" > <i class=\"fa fa-pencil\" aria-hidden=\"true\"> </i> Exercice 10 </h3>Coloriez la fleur.\n\n"},{"metadata":{"trusted":true},"cell_type":"code","source":"from turtle import *\n\ndef petale():\n for _ in range(2):\n circle(100, 120)\n left(60)\n\nfor _ in range(6):\n petale()\n left(60)\n\ndone()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<h3 style=\"color:teal;background-color:azure;\" > <i class=\"fa fa-pencil\" aria-hidden=\"true\"> </i> Exercice 11 </h3>\n\nAjoutez une fonction `m()` pour écrire le mot `nom`. Ajoutez ensuite des fonctions qui dessinent les lettres pour écrire votre prénom.\n"},{"metadata":{"trusted":true},"cell_type":"code","source":"from turtle import *\nwidth(5)\nr = 30\n\ndef n():\n down()\n left(90)\n forward(2*30) # montée\n backward(30) # retour au milieu\n circle(-30, 180) # demi-cercle\n forward(30) # descente\n left(90)\n up()\n forward(30) # avance vers la prochaine lettre\n\ndef o():\n forward(30) # avance vers milieu\n down()\n circle(30)\n up()\n forward(2*30) # avance vers prochaine lettre\n\nn()\no()\nn()\n\ndone()\n","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<h3 style=\"color:teal;background-color:azure;\" > <i class=\"fa fa-pencil\" aria-hidden=\"true\"> </i> Exercice 12</h3>\n\nAvec des rails de chemin de fer, dessinez un circuit en forme d'un rond (deux rails avec les traverses).\n\n\nUtilisez une boucle `for` pour la répétition des traverses.\n"},{"metadata":{"trusted":true},"cell_type":"code","source":"from turtle import *\n# Prénom Nom, classe\n\ndef traverse():\n ...\n\nforward(200)\n\ndone()\n","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<h3 style=\"color:teal;background-color:azure;\" > <i class=\"fa fa-pencil\" aria-hidden=\"true\"> </i> Exercice 13</h3>\n\nDessinez et coloriez un jardin. Définissez des fonctions pour des pétales, feuilles et fleurs.\n"},{"metadata":{"trusted":true},"cell_type":"code","source":"from turtle import *\n# Prénom Nom, classe\n\ndot(1000, 'lightgreen') # background\n\ndef petale():\n ...\ndef feuille():\n ...\ndef fleur():\n dot(50, 'red')\n\nfeuille()\nforward(200)\nfleur()\n\ndone()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<h3 style=\"color:teal;background-color:azure;\" > <i class=\"fa fa-pencil\" aria-hidden=\"true\"> </i> Exercice 14 (meubles) </h3>\n\nDéfinissez 3 fonctions pour dessiner une chaise, une table et un lit.\nEnsuite placez plusieurs meubles dans l'espace\n\n"},{"metadata":{"trusted":true},"cell_type":"code","source":"from turtle import *\n\ndef chaise():\n # à compléter...\n\ndef table():\n # à compléter...\n\ndef lit():\n # à compléter...\n\nchaise()\ntable()\nlit()\n\ndone()\n","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"display_name":"Python 3 (ipykernel)","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.10.12"}},"nbformat":4,"nbformat_minor":2} \ No newline at end of file +{"cells":[{"metadata":{},"cell_type":"markdown","source":"<div class = \"alert alert-danger\"> \n \nAttention: **veillez à bien sauvegarder votre travail** dans le bon dossier du disque réseau (dossier document) avec le bon nom (et l'extension *.ipynb*), **sinon toutes les modifications seront perdues!**\n\nPour reprendre votre travail, il suffit d'ouvrir le fichier .ipynb en cliquant sur *Fichier ouvrir*\n</div>"},{"metadata":{},"cell_type":"markdown","source":"# Le fonctions simples"},{"metadata":{},"cell_type":"markdown","source":"Rappel de quelques fonction de Turtle avec des exemples qui pourront vous servir\n\n| Fonction |Exemple|Commentaire|\n|:-------- |:------|:----------|\n|forward(x)|forward(150)|Trace un trait de 150 points|\n|backward(x)|backward(150)|Trace un trait “à reculons” de 150 points|\n|left(n)|left(60)|Tourne sur place la tortue de 60° à gauche|\n|right(n)|right(60)|Tourne sur place la tortue de 60° à droite|\n|width(x)|width(5)|Change l’épaisseur à 5 points|\n|color(\"c\")|color(\"yellow\")|Change la couleur du trait (mais aucun trait n’est tracé à ce moment). Notez les guillemets !|\n|penup()|penup()|Lève la tortue (permet de se déplacer sans dessiner)|\n|pendown()|pendown()|Baisse le stylo|\n|circle(R, A)|circle(100, 180)|Dessine un demi-cercle (angle de 180°) de rayon 100 points|\n|stamp()|stamp()|Laisse une impression de la tortue à sa position actuelle|\n|shape(forme)|shape('circle')|Change la forme de la tortue|"},{"metadata":{},"cell_type":"markdown","source":"# Définir - `def`\n\nDans ce chapitre, nous allons découvrir comment augmenter le vocabulaire de notre langage de programmation en définissant de nouvelles instructions, qu'on appelle aussi **fonction**. Ceci permet de rendre un code plus compact, mais surtout plus lisible. Nous allons voir que :\n\n- le mot-clé `def` permet de nommer (définir) une séquence,\n- le bloc qui suit doit être en **indentation** (décalé à droite),"},{"metadata":{},"cell_type":"markdown","source":"<h3 style=\"color:chocolate;background-color:papayawhip;\" > <i class=\"fa fa-question\" aria-hidden=\"true\"> </i> Quizz </h3> \n \n```\nUne fonction permet de\n\nA) donner un nom à une séquence\nB) augmenter le vocabulaire du langage de programmation\nC) nous dire si ça fonctionne\nD) rendre un programme plus lisible\n```"},{"metadata":{},"cell_type":"markdown","source":"<details>\n<summary style=\"border-left:3px solid #3c763d; border-radius:2pt; width:100%; color:#3c763d; padding:6px; background-color: #dff0d8\"> \nRéponse\n</summary> \n\n<div style=\"border-left:3px solid #3c763d; border-radius:2pt; color:#3c763d; padding:6px; background-color: #eff0e8\">\nA) donner un nom à une séquence\n\nB) augmenter le vocabulaire du langage de programmation\n\nD) rendre un programme plus lisible\n</div>\n</details>"},{"metadata":{},"cell_type":"markdown","source":"## Nommer une séquence\n\nDessiner un rectangle est assez utile. C'est une forme qu'on pourra réutiliser certainement souvent. Il serait pratique de définir un nom pour ces 8 lignes de code. Pouvons-nous définir de nouvelles commandes ?"},{"metadata":{"trusted":true},"cell_type":"code","source":"forward(160)\nleft(90)\nforward(100)\nleft(90)\nforward(160)\nleft(90)\nforward(100)\nleft(90)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Oui, c'est possible. Avec le mot-clé `def`, nous pouvons définir une nouvelle commande que nous pouvons par exemple appeler `rectangle()`.\nCette façon de créer un raccourci est appelée **définir** une fonction.\nLe code à exécuter suit l'expression `def rectangle():` et se trouve en **indentation** (décalé vers la droite).\n\nEnsuite, il suffit d'écrire `rectangle()` pour dessiner un rectangle. On appelle ceci **appeler** une fonction.\nRappelez-vous ceci :\n\n- on définit une fonction une seule fois,\n- on appelle une fonction autant de fois que l'on veut,\n- si on ne l'appelle pas, elle n'est pas exécutée et il ne se passe rien.\n\nDéfinir une fonction nous permet de réduire le nombre de lignes de code nécessaires.\nChaque fois que nous utilisons `rectangle()`,\nau lieu d'écrire 8 lignes, nous écrivons seulement une ligne de code."},{"metadata":{},"cell_type":"markdown","source":"<h3 style=\"color:teal;background-color:azure;\" > <i class=\"fa fa-pencil\" aria-hidden=\"true\"> </i> Exercice 1 </h3>\n\nDessinez encore d'autres rectangles en appelant la nouvelle fonction `rectangle()`.\n\n"},{"metadata":{"trusted":true},"cell_type":"code","source":"from turtle import *\n\ndef rectangle():\n forward(160)\n left(90)\n forward(100)\n left(90)\n forward(160)\n left(90)\n forward(100)\n left(90)\n\nrectangle()\nleft(90)\nrectangle()\n\ndone()\n","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<h3 style=\"color:chocolate;background-color:papayawhip;\" > <i class=\"fa fa-question\" aria-hidden=\"true\"> </i> Quizz </h3> \n \n```\nRappel: Une indentation de texte est\n\nA) un décalage vers la gauche\nB) un décalage vers la droite\nC) une mise en paragraphe\nD) une mise en sous-section\n```"},{"metadata":{},"cell_type":"markdown","source":"<details>\n<summary style=\"border-left:3px solid #3c763d; border-radius:2pt; width:100%; color:#3c763d; padding:6px; background-color: #dff0d8\"> \nRéponse\n</summary> \n\n<div style=\"border-left:3px solid #3c763d; border-radius:2pt; color:#3c763d; padding:6px; background-color: #eff0e8\">\nB) un décalage vers la droite\n</div>\n</details>"},{"metadata":{},"cell_type":"markdown","source":"## Donner du sens\n\nUne fonction ne permet pas seulement d'économiser des lignes de code.\nElle permet aussi de structurer le code et de lui donner un sens. Considérez par exemple le code ci-dessous. Il est presque impossible de comprendre ce que fait le programme en regardant les 17 lignes de code.\n\n"},{"metadata":{"trusted":true},"cell_type":"code","source":"from turtle import *\n\nforward(200)\nleft(90)\nforward(100)\nleft(90)\nforward(200)\nleft(90)\nforward(100)\nleft(90)\nforward(30)\nforward(30)\nleft(90)\nforward(50)\nleft(90)\nforward(30)\nleft(90)\nforward(50)\nleft(90)\n\ndone()\n","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Si nous observons la tortue, nous comprenons finalement qu'elle dessine deux fois un rectangle. Nous pouvons même interpréter cette image et donner le sens de bâtiment au premier rectangle, et de porte au second.\n\nEssayons maintenant de découper le code en **sous-programmes** en utilisant deux fonctions `batiment()` et `porte()`.\nEn regardant ces 3 lignes de code, on comprend immédiatement le sens du programme.\n\n``` python\nbatiment()\nforward(30) # repositionner la tortue\nporte()\n```\n\nLa définition d'une fonction permet d'ajouter de nouveaux mots à un langage de programmation. Contrairement aux commandes natives de Python qui sont toutes en anglais, nous sommes libres de les choisir en français.\n\n**Attention** : écrivez les fonctions sans accents et sans circonflexes : `batiment()`, `carre()`, `boite()`.\n\n"},{"metadata":{},"cell_type":"markdown","source":"<h3 style=\"color:teal;background-color:azure;\" > <i class=\"fa fa-pencil\" aria-hidden=\"true\"> </i> Exercice 2 </h3>Ajoutez une deuxième porte au bâtiment. Ensuite, faites-en une porte double.\n\n"},{"metadata":{"trusted":true},"cell_type":"code","source":"from turtle import *\n\ndef batiment():\n forward(200)\n left(90)\n forward(100)\n left(90)\n forward(200)\n left(90)\n forward(100)\n left(90)\n\ndef porte():\n forward(30)\n left(90)\n forward(50)\n left(90)\n forward(30)\n left(90)\n forward(50)\n left(90)\n\nbatiment()\nforward(30)\nporte()\n\ndone()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<h3 style=\"color:chocolate;background-color:papayawhip;\" > <i class=\"fa fa-question\" aria-hidden=\"true\"> </i> Quizz </h3> \n\nÀ combien de lignes de code la fonction `porte()` est-elle équivalente ?\n\n\n```\nA) 1 ligne\nB) 2 lignes\nC) 8 lignes\nD) 17 lignes\n```"},{"metadata":{},"cell_type":"markdown","source":"<details>\n<summary style=\"border-left:3px solid #3c763d; border-radius:2pt; width:100%; color:#3c763d; padding:6px; background-color: #dff0d8\"> \nRéponse\n</summary> \n\n<div style=\"border-left:3px solid #3c763d; border-radius:2pt; color:#3c763d; padding:6px; background-color: #eff0e8\">\nC) 8 lignes\n</div>\n</details>"},{"metadata":{},"cell_type":"markdown","source":"## Définir une fonction\n\nLe fait de donner un nom à une séquence d'instructions est appelé **définir une fonction**. Une **définition de fonction** comporte :\n\n1. le mot-clé `def` (définir),\n1. le nom de la fonction (`batiment/porte`),\n1. les parenthèses `()`,\n1. le deux-points `:`,\n1. un bloc en indentation.\n\nQu'est-ce qu'un bloc en indentation ?\nC'est un bloc de texte qui comporte des espaces vides à gauche. En Python, ces espaces apparaissent en multiples de 4.\n\nL'indentation est très importante en Python. C'est l'indentation qui indique l'étendue des instructions qui font partie de la fonction.\n\n"},{"metadata":{},"cell_type":"markdown","source":"<h3 style=\"color:chocolate;background-color:papayawhip;\" > <i class=\"fa fa-question\" aria-hidden=\"true\"> </i> Quizz </h3> \n \n```\nParmi les 4 définitions de fonction ci-dessous, laquelle est correcte ?\n\nA) def() rectangle:\nB) def: rectangle\nC) def rectangle():\nD) def(rectangle):\n```"},{"metadata":{},"cell_type":"markdown","source":"<details>\n<summary style=\"border-left:3px solid #3c763d; border-radius:2pt; width:100%; color:#3c763d; padding:6px; background-color: #dff0d8\"> \nRéponse\n</summary> \n\n<div style=\"border-left:3px solid #3c763d; border-radius:2pt; color:#3c763d; padding:6px; background-color: #eff0e8\">\nC) def rectangle():\n</div>\n</details>"},{"metadata":{},"cell_type":"markdown","source":"## Indenter avec un raccourci\n\nComme l'indentation est tellement importante en Python, il en existe un raccourci.\nIl faut d'abord sélectionner **les lignes** de code dont vous voulez changer l'indentation.\nEnsuite, vous appuyez sur :\n\n- la touche **tab** pour augmenter l'indentation\n- la touche **maj+tab** pour diminuer l'indentation\n\n"},{"metadata":{},"cell_type":"markdown","source":"<h3 style=\"color:teal;background-color:azure;\" > <i class=\"fa fa-pencil\" aria-hidden=\"true\"> </i> Exercice 3 </h3>Essayez ces raccourcis dans le code ci-dessous. Transformez le code en deux fonctions `batiment()` et `porte()`, que vous appelez ensuite.\n\n"},{"metadata":{"trusted":true},"cell_type":"code","source":"from turtle import *\n\nforward(200)\nleft(90)\nforward(100)\nleft(90)\nforward(200)\nleft(90)\nforward(100)\nleft(90)\nforward(30)\nforward(30)\nleft(90)\nforward(50)\nleft(90)\nforward(30)\nleft(90)\nforward(50)\nleft(90)\n\ndone()\n","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Voici encore un raccourci très utile : **maj(ou Shift)+Enter** pour exécuter le code.\n\n"},{"metadata":{},"cell_type":"markdown","source":"## Maison avec porte\n\nUne fois qu'une fonction est définie, elle peut être utilisée partout, même dans la définition d'une autre fonction.\n\nIci, nous avons une fonction `porte()`, qui est utilisée à l'intérieur d'une deuxième fonction `maison()`. Pour que ceci soit possible, la définition de porte doit être placée avant la définition de `maison()`.\n\n"},{"metadata":{},"cell_type":"markdown","source":"<h3 style=\"color:teal;background-color:azure;\" > <i class=\"fa fa-pencil\" aria-hidden=\"true\"> </i> Exercice 4 </h3>Déplacez la porte vers le milieu de la maison, et dessinez une deuxième maison à coté.\n\n"},{"metadata":{"trusted":true},"cell_type":"code","source":"from turtle import *\n\ndef porte():\n forward(20)\n left(90)\n forward(40)\n left(90)\n forward(20)\n left(90)\n forward(40)\n left(90)\n\ndef maison():\n forward(100)\n left(90)\n forward(60)\n left(45)\n forward(71)\n left(90)\n forward(71)\n left(45)\n forward(60)\n left(90)\n porte()\n\nmaison()\n\ndone()\n","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## Plus sur \"La tortue\"\n"},{"metadata":{},"cell_type":"markdown","source":"### Le point `dot()`\n\nLa fonction `dot()` dessine un point à la position actuelle de la tortue."},{"metadata":{},"cell_type":"markdown","source":"<h3 style=\"color:teal;background-color:azure;\" > <i class=\"fa fa-pencil\" aria-hidden=\"true\"> </i> Exercice 5 </h3>Ajoutez un point (`dot`) au sommet du triangle.\n\n"},{"metadata":{"trusted":true},"cell_type":"code","source":"from turtle import *\n\ndef triangle():\n dot()\n forward(100)\n left(120)\n dot()\n forward(100)\n left(120)\n forward(100)\n\ntriangle()\n\ndone()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"### Lever le stylo\n\nLes deux commandes `up()` et `down()` permettent de lever et de baisser le stylo.\nCeci nous permet de dessiner des formes séparées, comme ici le petit i avec son point.\n"},{"metadata":{},"cell_type":"markdown","source":"<h3 style=\"color:teal;background-color:azure;\" > <i class=\"fa fa-pencil\" aria-hidden=\"true\"> </i> Exercice 6 </h3>Transformez le i vers un i avec trema (deux points).\n"},{"metadata":{"trusted":true},"cell_type":"code","source":"from turtle import *\n\ndef i():\n dot()\n pendown() # poser le stylo\n left(90)\n forward(50)\n penup() # lever le stylo\n forward(50)\n dot()\n backward(2*50)\n right(90)\n forward(50/2) # avancer à la prochaine lettre\n\ni()\ni()\n\ndone()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## Exercices d'entraînement\n\n<h3 style=\"color:teal;background-color:azure;\" > <i class=\"fa fa-pencil\" aria-hidden=\"true\"> </i> Exercice 7 </h3>\n\nCompléter le programme ci-dessous en ajoutant des appels à la fonction `forme_mystere()` pour pour créer le dessin suivant:\n"},{"metadata":{"trusted":true},"cell_type":"code","source":"# permet d'utiliser les fonctions pour dessiner\nfrom turtle import *\n\n# Définition de la fonction mystère\ndef forme_mystere():\n for k in range(4):\n forward(100)\n right(90)\n\n\nforme_mystere()\n# à compléter \n\ndone()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<h3 style=\"color:teal;background-color:azure;\" > <i class=\"fa fa-pencil\" aria-hidden=\"true\"> </i> Exercice 8 </h3>\n\n1. Testez le programme suivant."},{"metadata":{"trusted":true},"cell_type":"code","source":"# permet d'utiliser les fonctions pour dessiner\nfrom turtle import *\n\n# Code à factoriser\nfor k in range(6):\n forward(200)\n right(60)\nright(60)\nfor k in range(6):\n forward(200)\n right(60)\nright(60)\nfor k in range(6):\n forward(200)\n right(60)\nright(60)\nfor k in range(6):\n forward(200)\n right(60)\nright(60)\nfor k in range(6):\n forward(200)\n right(60)\nright(60)\nfor k in range(6):\n forward(200)\n right(60)\nright(60)\n\ndone()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"2. Définissez une fonction `hexagone()` qui permet de tracer des hexagones et utilisez-là pour réduire le nombre d’instructions du programme précédent."},{"metadata":{"trusted":true},"cell_type":"code","source":"# permet d'utiliser les fonctions pour dessiner\nfrom turtle import *\n\ndef #a compléter\n #a compléter\n\n#a compléter\n\ndone()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<h3 style=\"color:teal;background-color:azure;\" > <i class=\"fa fa-pencil\" aria-hidden=\"true\"> </i> Exercice 9 </h3>\n\nTestez le programme ci-dessous, puis modifiez le en définissant au début une fonction `carre100()` qui dessine un carré de longueur 100 afin d'obtenir un programme structuré sans répétition inutile."},{"metadata":{"trusted":true},"cell_type":"code","source":"from turtle import *\n\n\nfor _ in range(4):\n forward(100)\n left(90)\n\n\nleft(180)\n\n\nfor _ in range(4):\n forward(100)\n left(90)\n\ndone()\n","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<h3 style=\"color:teal;background-color:azure;\" > <i class=\"fa fa-pencil\" aria-hidden=\"true\"> </i> Exercice 10 </h3>\nDans le programme ci-dessous:\n\n1. Définissez une fonction `triangle100()` pour dessiner un triangle équilatéral de côté 100 comme dans l’illustration A.\n \n2. Utilisez `triangle100()` pour dessiner une forme comme dans l’illustration B.\n\n"},{"metadata":{"trusted":true},"cell_type":"code","source":"from turtle import *\n\n# à compléter\n\ndone()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<h3 style=\"color:teal;background-color:azure;\" > <i class=\"fa fa-pencil\" aria-hidden=\"true\"> </i> Exercice 11 </h3>\n\nUtilisez les commandes `carre100()` et `triangle100()` définies dans les exercices 9 et 10 pour dessiner une figure semblable à celle représentée ci-dessous.\n"},{"metadata":{"trusted":true},"cell_type":"code","source":"from turtle import *\n\n# à compléter\n\ndone()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<h3 style=\"color:teal;background-color:azure;\" > <i class=\"fa fa-pencil\" aria-hidden=\"true\"> </i> Exercice 12 </h3>\n\nDans le programme ci-dessous:\n\n1. Définissez une fonction `carre_ouvert()` qui dessine un carré ouvert comme dans l’illustration A.\n\n \n2. Utilisez `triangle100()` pour dessiner une croix comme dans l’illustration B.\n\n"},{"metadata":{"trusted":true},"cell_type":"code","source":"from turtle import *\n\n# à compléter\n\ndone()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<h3 style=\"color:teal;background-color:azure;\" > <i class=\"fa fa-pencil\" aria-hidden=\"true\"> </i> Exercice 13 </h3>\n\nCréez une fonction `paquebot()` et utilisez pour dessiner deux paquebots."},{"metadata":{"trusted":true},"cell_type":"code","source":"from turtle import *\n\nforward(200)\nleft(80)\nforward(60)\nleft(100)\nforward(220)\nleft(100)\nforward(60)\n\npenup()\nleft(125)\nforward(30)\nright(45)\n\nfor i in range(6):\n pendown()\n circle(10, 360)\n penup()\n forward(30)\n \n\ndone()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<h3 style=\"color:teal;background-color:azure;\" > <i class=\"fa fa-pencil\" aria-hidden=\"true\"> </i> Exercice 14 </h3>\n\nUtilisez l'instruction `carre100()` définie dans l'exercices 9 pour réaliser le programme qui dessine d’abord 2 carrés décalés d’un angle de 20° (figure A) et ensuite la figure avec 18 carrés (figure B)..\n"},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<h3 style=\"color:teal;background-color:azure;\" > <i class=\"fa fa-pencil\" aria-hidden=\"true\"> </i> Exercice 15 </h3>Coloriez la fleur.\n\n"},{"metadata":{"trusted":true},"cell_type":"code","source":"from turtle import *\n\ndef petale():\n for _ in range(2):\n circle(100, 120)\n left(60)\n\nfor _ in range(6):\n petale()\n left(60)\n\ndone()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<h3 style=\"color:teal;background-color:azure;\" > <i class=\"fa fa-pencil\" aria-hidden=\"true\"> </i> Exercice 16 </h3>\n\nAjoutez une fonction `m()` pour écrire le mot `nom`. Ajoutez ensuite des fonctions qui dessinent les lettres pour écrire votre prénom.\n"},{"metadata":{"trusted":true},"cell_type":"code","source":"from turtle import *\nwidth(5)\n\ndef n():\n down()\n left(90)\n forward(2*30) # montée\n backward(30) # retour au milieu\n circle(-30, 180) # demi-cercle\n forward(30) # descente\n left(90)\n up()\n forward(30) # avance vers la prochaine lettre\n\ndef o():\n forward(30) # avance vers milieu\n down()\n circle(30)\n up()\n forward(2*30) # avance vers prochaine lettre\n\nn()\no()\nn()\n\ndone()\n","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<h3 style=\"color:teal;background-color:azure;\" > <i class=\"fa fa-pencil\" aria-hidden=\"true\"> </i> Exercice 17</h3>\n\nDessinez et coloriez un jardin. Définissez des fonctions pour des pétales, feuilles et fleurs.\n\n*Indication: Inspirez vous de l'exercice 15.*"},{"metadata":{"trusted":true},"cell_type":"code","source":"from turtle import *\n# Prénom Nom, classe\n\ndot(1000, 'lightgreen') # background\n\ndef petale():\n ...\ndef feuille():\n ...\ndef fleur():\n dot(50, 'red')\n\nfeuille()\nforward(200)\nfleur()\n\ndone()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<h3 style=\"color:teal;background-color:azure;\" > <i class=\"fa fa-pencil\" aria-hidden=\"true\"> </i> Exercice 18 (meubles) </h3>\n\nDéfinissez 3 fonctions pour dessiner une chaise, une table et un lit.\nEnsuite placez plusieurs meubles dans l'espace\n\n"},{"metadata":{"trusted":true},"cell_type":"code","source":"from turtle import *\n\ndef chaise():\n # à compléter...\n\ndef table():\n # à compléter...\n\ndef lit():\n # à compléter...\n\nchaise()\ntable()\nlit()\n\ndone()\n","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<h3 style=\"color:teal;background-color:azure;\" > <i class=\"fa fa-pencil\" aria-hidden=\"true\"> </i> Exercice 19 </h3>\n\nUtiliser votre identifiant EEL et le mot de passe *Sismondi2024* pour faire les exercices de la **série D** de la plateforme [AlgoPython](https://www.algopython.fr/login). [](https://www.algopython.fr/login)\n\n\n"},{"metadata":{},"cell_type":"markdown","source":"---\n\n#### Remarque générale\n\nCe document est une adaptation d'un ressource pédagogique tiré du catalogue modulo https://modulo-info.ch/. Il est sous license Creative Commons [BY-NC-SA](https://creativecommons.org/licenses/?lang=fr)\n\n"},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"display_name":"Python 3 (ipykernel)","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.10.12"}},"nbformat":4,"nbformat_minor":2} \ No newline at end of file diff --git a/Notebooks/Exo_supp.ipynb b/Notebooks/Exo_supp.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..51a7c75d4fd33b4d313de46e5fb31d61559723ee --- /dev/null +++ b/Notebooks/Exo_supp.ipynb @@ -0,0 +1 @@ +{"cells":[{"metadata":{},"cell_type":"markdown","source":"### Paquebot\n\nUne boucle `for` est utilisée dans l'exemple suivant pour dessiner les hublots d'un paquebot. Les hublots sont numérotés en utilisant la variable `i`.\n"},{"metadata":{},"cell_type":"markdown","source":"<h3 style=\"color:teal;background-color:azure;\" > <i class=\"fa fa-pencil\" aria-hidden=\"true\"> </i> Exercice 8 </h3>\n\nCréez une fonction `paquebot()` et dessinez-en un deuxième.\n"},{"metadata":{"trusted":false},"cell_type":"code","source":"from turtle import *\n\nforward(200)\nleft(80)\nforward(60)\nleft(100)\nforward(220)\nleft(100)\nforward(60)\n\nup()\nleft(125)\nforward(40)\nright(45)\n\nfor i in range(6):\n dot(20, 'lightgray')\n write(i, font=('Arial', 20, 'normal'))\n forward(30)\n\ndone()","execution_count":1,"outputs":[{"output_type":"display_data","data":{"image/svg+xml":"<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"50%\" height=\"auto\" preserveaspectratio=\"xMidYMid meet\" viewbox=\"0 0 640 480\"><animate id=\"af_c15caa80776d4f93896328234a9ad966_0\" attributename=\"opacity\" attributetype=\"CSS\" from=\"1\" to=\"1\" begin=\"0s\" dur=\"1ms\" fill=\"freeze\"></animate><g transform=\"translate(320 240)\"></g><g transform=\"translate(320 240)\"><line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"0\" style=\"stroke: black;stroke-width: 1\"><animate id=\"af_c15caa80776d4f93896328234a9ad966_2\" attributename=\"x2\" attributetype=\"XML\" from=\"0\" to=\"0\" dur=\"1ms\" fill=\"freeze\" begin=\"af_c15caa80776d4f93896328234a9ad966_1.end\"></animate><animate attributename=\"y2\" attributetype=\"XML\" begin=\"af_c15caa80776d4f93896328234a9ad966_1.end\" from=\"0\" to=\"0\" dur=\"1ms\" fill=\"freeze\"></animate></line><line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"0\" style=\"stroke: black;stroke-width: 1\"><animate id=\"af_c15caa80776d4f93896328234a9ad966_5\" attributename=\"x2\" attributetype=\"XML\" from=\"0\" to=\"200\" dur=\" 1.070s\" fill=\"freeze\" begin=\"af_c15caa80776d4f93896328234a9ad966_4.end\"></animate><animate attributename=\"y2\" attributetype=\"XML\" begin=\"af_c15caa80776d4f93896328234a9ad966_4.end\" from=\"0\" to=\"0\" dur=\" 1.070s\" fill=\"freeze\"></animate></line><line x1=\"200\" y1=\"0\" x2=\"200\" y2=\"0\" style=\"stroke: black;stroke-width: 1\"><animate id=\"af_c15caa80776d4f93896328234a9ad966_7\" attributename=\"x2\" attributetype=\"XML\" from=\"200\" to=\"210.41889066001582\" dur=\" 0.321s\" fill=\"freeze\" begin=\"af_c15caa80776d4f93896328234a9ad966_6.end\"></animate><animate attributename=\"y2\" attributetype=\"XML\" begin=\"af_c15caa80776d4f93896328234a9ad966_6.end\" from=\"0\" to=\"-59.088465180732484\" dur=\" 0.321s\" fill=\"freeze\"></animate></line><line x1=\"210.41889066001582\" y1=\"-59.088465180732484\" x2=\"210.41889066001582\" y2=\"-59.088465180732484\" style=\"stroke: black;stroke-width: 1\"><animate id=\"af_c15caa80776d4f93896328234a9ad966_9\" attributename=\"x2\" attributetype=\"XML\" from=\"210.41889066001582\" to=\"-9.581109339984181\" dur=\" 1.177s\" fill=\"freeze\" begin=\"af_c15caa80776d4f93896328234a9ad966_8.end\"></animate><animate attributename=\"y2\" attributetype=\"XML\" begin=\"af_c15caa80776d4f93896328234a9ad966_8.end\" from=\"-59.088465180732484\" to=\"-59.08846518073251\" dur=\" 1.177s\" fill=\"freeze\"></animate></line><line x1=\"-9.581109339984181\" y1=\"-59.08846518073251\" x2=\"-9.581109339984181\" y2=\"-59.08846518073251\" style=\"stroke: black;stroke-width: 1\"><animate id=\"af_c15caa80776d4f93896328234a9ad966_11\" attributename=\"x2\" attributetype=\"XML\" from=\"-9.581109339984181\" to=\"0.8377813200316169\" dur=\" 0.321s\" fill=\"freeze\" begin=\"af_c15caa80776d4f93896328234a9ad966_10.end\"></animate><animate attributename=\"y2\" attributetype=\"XML\" begin=\"af_c15caa80776d4f93896328234a9ad966_10.end\" from=\"-59.08846518073251\" to=\"-2.842170943040401e-14\" dur=\" 0.321s\" fill=\"freeze\"></animate></line><line x1=\"0.8377813200316169\" y1=\"-2.842170943040401e-14\" x2=\"0.8377813200316169\" y2=\"-2.842170943040401e-14\" style=\"stroke: black;stroke-width: 1\" opacity=\"0\"><animate id=\"af_c15caa80776d4f93896328234a9ad966_13\" attributename=\"x2\" attributetype=\"XML\" from=\"0.8377813200316169\" to=\"29.122052567493526\" dur=\" 0.214s\" fill=\"freeze\" begin=\"af_c15caa80776d4f93896328234a9ad966_12.end\"></animate></line><circle cx=\"29.122052567493526\" cy=\"-28.284271247461923\" r=\"10\" fill=\"lightgray\" style=\"display: none;\"><animate id=\"af_c15caa80776d4f93896328234a9ad966_15\" attributename=\"display\" attributetype=\"CSS\" from=\"block\" to=\"block\" dur=\"1ms\" fill=\"freeze\" begin=\"af_c15caa80776d4f93896328234a9ad966_14.end\"></animate></circle><line x1=\"29.122052567493526\" y1=\"-28.284271247461923\" x2=\"29.122052567493526\" y2=\"-28.284271247461923\" style=\"stroke: black;stroke-width: 1\" opacity=\"0\"><animate id=\"af_c15caa80776d4f93896328234a9ad966_17\" attributename=\"x2\" attributetype=\"XML\" from=\"29.122052567493526\" to=\"59.122052567493526\" dur=\" 0.161s\" fill=\"freeze\" begin=\"af_c15caa80776d4f93896328234a9ad966_16.end\"></animate></line><circle cx=\"59.122052567493526\" cy=\"-28.284271247461916\" r=\"10\" fill=\"lightgray\" style=\"display: none;\"><animate id=\"af_c15caa80776d4f93896328234a9ad966_18\" attributename=\"display\" attributetype=\"CSS\" from=\"block\" to=\"block\" dur=\"1ms\" fill=\"freeze\" begin=\"af_c15caa80776d4f93896328234a9ad966_17.end\"></animate></circle><line x1=\"59.122052567493526\" y1=\"-28.284271247461916\" x2=\"59.122052567493526\" y2=\"-28.284271247461916\" style=\"stroke: black;stroke-width: 1\" opacity=\"0\"><animate id=\"af_c15caa80776d4f93896328234a9ad966_20\" attributename=\"x2\" attributetype=\"XML\" from=\"59.122052567493526\" to=\"89.12205256749353\" dur=\" 0.161s\" fill=\"freeze\" begin=\"af_c15caa80776d4f93896328234a9ad966_19.end\"></animate></line><circle cx=\"89.12205256749353\" cy=\"-28.28427124746191\" r=\"10\" fill=\"lightgray\" style=\"display: none;\"><animate id=\"af_c15caa80776d4f93896328234a9ad966_21\" attributename=\"display\" attributetype=\"CSS\" from=\"block\" to=\"block\" dur=\"1ms\" fill=\"freeze\" begin=\"af_c15caa80776d4f93896328234a9ad966_20.end\"></animate></circle><line x1=\"89.12205256749353\" y1=\"-28.28427124746191\" x2=\"89.12205256749353\" y2=\"-28.28427124746191\" style=\"stroke: black;stroke-width: 1\" opacity=\"0\"><animate id=\"af_c15caa80776d4f93896328234a9ad966_23\" attributename=\"x2\" attributetype=\"XML\" from=\"89.12205256749353\" to=\"119.12205256749353\" dur=\" 0.161s\" fill=\"freeze\" begin=\"af_c15caa80776d4f93896328234a9ad966_22.end\"></animate></line><circle cx=\"119.12205256749353\" cy=\"-28.284271247461902\" r=\"10\" fill=\"lightgray\" style=\"display: none;\"><animate id=\"af_c15caa80776d4f93896328234a9ad966_24\" attributename=\"display\" attributetype=\"CSS\" from=\"block\" to=\"block\" dur=\"1ms\" fill=\"freeze\" begin=\"af_c15caa80776d4f93896328234a9ad966_23.end\"></animate></circle><line x1=\"119.12205256749353\" y1=\"-28.284271247461902\" x2=\"119.12205256749353\" y2=\"-28.284271247461902\" style=\"stroke: black;stroke-width: 1\" opacity=\"0\"><animate id=\"af_c15caa80776d4f93896328234a9ad966_26\" attributename=\"x2\" attributetype=\"XML\" from=\"119.12205256749353\" to=\"149.12205256749354\" dur=\" 0.161s\" fill=\"freeze\" begin=\"af_c15caa80776d4f93896328234a9ad966_25.end\"></animate></line><circle cx=\"149.12205256749354\" cy=\"-28.284271247461895\" r=\"10\" fill=\"lightgray\" style=\"display: none;\"><animate id=\"af_c15caa80776d4f93896328234a9ad966_27\" attributename=\"display\" attributetype=\"CSS\" from=\"block\" to=\"block\" dur=\"1ms\" fill=\"freeze\" begin=\"af_c15caa80776d4f93896328234a9ad966_26.end\"></animate></circle><line x1=\"149.12205256749354\" y1=\"-28.284271247461895\" x2=\"149.12205256749354\" y2=\"-28.284271247461895\" style=\"stroke: black;stroke-width: 1\" opacity=\"0\"><animate id=\"af_c15caa80776d4f93896328234a9ad966_29\" attributename=\"x2\" attributetype=\"XML\" from=\"149.12205256749354\" to=\"179.12205256749354\" dur=\" 0.161s\" fill=\"freeze\" begin=\"af_c15caa80776d4f93896328234a9ad966_28.end\"></animate></line><circle cx=\"179.12205256749354\" cy=\"-28.284271247461888\" r=\"10\" fill=\"lightgray\" style=\"display: none;\"><animate id=\"af_c15caa80776d4f93896328234a9ad966_30\" attributename=\"display\" attributetype=\"CSS\" from=\"block\" to=\"block\" dur=\"1ms\" fill=\"freeze\" begin=\"af_c15caa80776d4f93896328234a9ad966_29.end\"></animate></circle><line x1=\"179.12205256749354\" y1=\"-28.284271247461888\" x2=\"179.12205256749354\" y2=\"-28.284271247461888\" style=\"stroke: black;stroke-width: 1\" opacity=\"0\"><animate id=\"af_c15caa80776d4f93896328234a9ad966_32\" attributename=\"x2\" attributetype=\"XML\" from=\"179.12205256749354\" to=\"209.12205256749354\" dur=\" 0.161s\" fill=\"freeze\" begin=\"af_c15caa80776d4f93896328234a9ad966_31.end\"></animate></line></g><g transform=\"translate(320 240)\"><text x=\"29.122052567493526\" y=\"-28.284271247461923\" fill=\"black\" style=\"display: none;font-family: Arial;font-size: 20;font-style: normal\" text-anchor=\"start\">0<animate id=\"af_c15caa80776d4f93896328234a9ad966_16\" attributename=\"display\" attributetype=\"CSS\" from=\"block\" to=\"block\" dur=\"1ms\" fill=\"freeze\" begin=\"af_c15caa80776d4f93896328234a9ad966_15.end\"></animate></text><text x=\"59.122052567493526\" y=\"-28.284271247461916\" fill=\"black\" style=\"display: none;font-family: Arial;font-size: 20;font-style: normal\" text-anchor=\"start\">1<animate id=\"af_c15caa80776d4f93896328234a9ad966_19\" attributename=\"display\" attributetype=\"CSS\" from=\"block\" to=\"block\" dur=\"1ms\" fill=\"freeze\" begin=\"af_c15caa80776d4f93896328234a9ad966_18.end\"></animate></text><text x=\"89.12205256749353\" y=\"-28.28427124746191\" fill=\"black\" style=\"display: none;font-family: Arial;font-size: 20;font-style: normal\" text-anchor=\"start\">2<animate id=\"af_c15caa80776d4f93896328234a9ad966_22\" attributename=\"display\" attributetype=\"CSS\" from=\"block\" to=\"block\" dur=\"1ms\" fill=\"freeze\" begin=\"af_c15caa80776d4f93896328234a9ad966_21.end\"></animate></text><text x=\"119.12205256749353\" y=\"-28.284271247461902\" fill=\"black\" style=\"display: none;font-family: Arial;font-size: 20;font-style: normal\" text-anchor=\"start\">3<animate id=\"af_c15caa80776d4f93896328234a9ad966_25\" attributename=\"display\" attributetype=\"CSS\" from=\"block\" to=\"block\" dur=\"1ms\" fill=\"freeze\" begin=\"af_c15caa80776d4f93896328234a9ad966_24.end\"></animate></text><text x=\"149.12205256749354\" y=\"-28.284271247461895\" fill=\"black\" style=\"display: none;font-family: Arial;font-size: 20;font-style: normal\" text-anchor=\"start\">4<animate id=\"af_c15caa80776d4f93896328234a9ad966_28\" attributename=\"display\" attributetype=\"CSS\" from=\"block\" to=\"block\" dur=\"1ms\" fill=\"freeze\" begin=\"af_c15caa80776d4f93896328234a9ad966_27.end\"></animate></text><text x=\"179.12205256749354\" y=\"-28.284271247461888\" fill=\"black\" style=\"display: none;font-family: Arial;font-size: 20;font-style: normal\" text-anchor=\"start\">5<animate id=\"af_c15caa80776d4f93896328234a9ad966_31\" attributename=\"display\" attributetype=\"CSS\" from=\"block\" to=\"block\" dur=\"1ms\" fill=\"freeze\" begin=\"af_c15caa80776d4f93896328234a9ad966_30.end\"></animate></text></g><g transform=\"translate(320 240)\"><polygon points=\"0,16 -2,14 -1,10 -4,7 -7,9 -9,8 -6,5 -7,1 -5,-3 -8,-6 -6,-8 -4,-5 0,-7 4,-5 6,-8 8,-6 5,-3 7,1 6,5 9,8 7,9 4,7 1,10 2,14\" stroke=\"black\" fill=\"black\" stroke-width=\"1\" opacity=\"0\"><animate id=\"af_c15caa80776d4f93896328234a9ad966_1\" begin=\"af_c15caa80776d4f93896328234a9ad966_0.end\" dur=\"1ms\" fill=\"freeze\" attributename=\"opacity\" attributetype=\"XML\" from=\"0\" to=\"1\"></animate><animateMotion begin=\"af_c15caa80776d4f93896328234a9ad966_2.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateTransform attributename=\"transform\" id=\"af_c15caa80776d4f93896328234a9ad966_3\" type=\"rotate\" from=\"0,0,0\" to=\"0.0,0,0\" begin=\"af_c15caa80776d4f93896328234a9ad966_2.end\" dur=\"1ms\" fill=\"freeze\"></animateTransform><animateMotion begin=\"af_c15caa80776d4f93896328234a9ad966_3.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateTransform attributename=\"transform\" id=\"af_c15caa80776d4f93896328234a9ad966_4\" type=\"rotate\" from=\"-90.0,0,0\" to=\"-90.0,0,0\" begin=\"af_c15caa80776d4f93896328234a9ad966_3.end\" dur=\"1ms\" fill=\"freeze\"></animateTransform><animateMotion begin=\"af_c15caa80776d4f93896328234a9ad966_4.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateMotion from=\"0.0,-0.0\" to=\"200.0,-0.0\" dur=\" 1.070s\" begin=\"af_c15caa80776d4f93896328234a9ad966_4.end\" fill=\"freeze\"></animateMotion><animateMotion begin=\"af_c15caa80776d4f93896328234a9ad966_5.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateTransform attributename=\"transform\" id=\"af_c15caa80776d4f93896328234a9ad966_6\" type=\"rotate\" from=\"-90.0,0,0\" to=\"-170.0,0,0\" begin=\"af_c15caa80776d4f93896328234a9ad966_5.end\" dur=\" 0.074s\" fill=\"freeze\"></animateTransform><animateMotion begin=\"af_c15caa80776d4f93896328234a9ad966_6.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateMotion from=\"200.0,-0.0\" to=\"210.41889066001582,-59.088465180732484\" dur=\" 0.321s\" begin=\"af_c15caa80776d4f93896328234a9ad966_6.end\" fill=\"freeze\"></animateMotion><animateMotion begin=\"af_c15caa80776d4f93896328234a9ad966_7.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateTransform attributename=\"transform\" id=\"af_c15caa80776d4f93896328234a9ad966_8\" type=\"rotate\" from=\"-170.0,0,0\" to=\"-270.0,0,0\" begin=\"af_c15caa80776d4f93896328234a9ad966_7.end\" dur=\" 0.093s\" fill=\"freeze\"></animateTransform><animateMotion begin=\"af_c15caa80776d4f93896328234a9ad966_8.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateMotion from=\"210.41889066001582,-59.088465180732484\" to=\"-9.581109339984181,-59.08846518073251\" dur=\" 1.177s\" begin=\"af_c15caa80776d4f93896328234a9ad966_8.end\" fill=\"freeze\"></animateMotion><animateMotion begin=\"af_c15caa80776d4f93896328234a9ad966_9.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateTransform attributename=\"transform\" id=\"af_c15caa80776d4f93896328234a9ad966_10\" type=\"rotate\" from=\"-270.0,0,0\" to=\"-370.0,0,0\" begin=\"af_c15caa80776d4f93896328234a9ad966_9.end\" dur=\" 0.093s\" fill=\"freeze\"></animateTransform><animateMotion begin=\"af_c15caa80776d4f93896328234a9ad966_10.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateMotion from=\"-9.581109339984181,-59.08846518073251\" to=\"0.8377813200316169,-2.842170943040401e-14\" dur=\" 0.321s\" begin=\"af_c15caa80776d4f93896328234a9ad966_10.end\" fill=\"freeze\"></animateMotion><animateMotion begin=\"af_c15caa80776d4f93896328234a9ad966_11.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateTransform attributename=\"transform\" id=\"af_c15caa80776d4f93896328234a9ad966_12\" type=\"rotate\" from=\"-370.0,0,0\" to=\"-495.0,0,0\" begin=\"af_c15caa80776d4f93896328234a9ad966_11.end\" dur=\" 0.116s\" fill=\"freeze\"></animateTransform><animateMotion begin=\"af_c15caa80776d4f93896328234a9ad966_12.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateMotion from=\"0.8377813200316169,-2.842170943040401e-14\" to=\"29.122052567493526,-28.284271247461923\" dur=\" 0.214s\" begin=\"af_c15caa80776d4f93896328234a9ad966_12.end\" fill=\"freeze\"></animateMotion><animateMotion begin=\"af_c15caa80776d4f93896328234a9ad966_13.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateTransform attributename=\"transform\" id=\"af_c15caa80776d4f93896328234a9ad966_14\" type=\"rotate\" from=\"-495.0,0,0\" to=\"-450.0,0,0\" begin=\"af_c15caa80776d4f93896328234a9ad966_13.end\" dur=\" 0.042s\" fill=\"freeze\"></animateTransform><animateMotion begin=\"af_c15caa80776d4f93896328234a9ad966_16.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateMotion from=\"29.122052567493526,-28.284271247461923\" to=\"59.122052567493526,-28.284271247461916\" dur=\" 0.161s\" begin=\"af_c15caa80776d4f93896328234a9ad966_16.end\" fill=\"freeze\"></animateMotion><animateMotion begin=\"af_c15caa80776d4f93896328234a9ad966_19.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateMotion from=\"59.122052567493526,-28.284271247461916\" to=\"89.12205256749353,-28.28427124746191\" dur=\" 0.161s\" begin=\"af_c15caa80776d4f93896328234a9ad966_19.end\" fill=\"freeze\"></animateMotion><animateMotion begin=\"af_c15caa80776d4f93896328234a9ad966_22.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateMotion from=\"89.12205256749353,-28.28427124746191\" to=\"119.12205256749353,-28.284271247461902\" dur=\" 0.161s\" begin=\"af_c15caa80776d4f93896328234a9ad966_22.end\" fill=\"freeze\"></animateMotion><animateMotion begin=\"af_c15caa80776d4f93896328234a9ad966_25.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateMotion from=\"119.12205256749353,-28.284271247461902\" to=\"149.12205256749354,-28.284271247461895\" dur=\" 0.161s\" begin=\"af_c15caa80776d4f93896328234a9ad966_25.end\" fill=\"freeze\"></animateMotion><animateMotion begin=\"af_c15caa80776d4f93896328234a9ad966_28.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateMotion from=\"149.12205256749354,-28.284271247461895\" to=\"179.12205256749354,-28.284271247461888\" dur=\" 0.161s\" begin=\"af_c15caa80776d4f93896328234a9ad966_28.end\" fill=\"freeze\"></animateMotion><animateMotion begin=\"af_c15caa80776d4f93896328234a9ad966_31.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateMotion from=\"179.12205256749354,-28.284271247461888\" to=\"209.12205256749354,-28.28427124746188\" dur=\" 0.161s\" begin=\"af_c15caa80776d4f93896328234a9ad966_31.end\" fill=\"freeze\"></animateMotion></polygon></g></svg>"},"metadata":{}}]},{"metadata":{"trusted":true},"cell_type":"markdown","source":"<h3 style=\"color:teal;background-color:azure;\" > <i class=\"fa fa-pencil\" aria-hidden=\"true\"> </i> Exercice 12</h3>\n\nAvec des rails de chemin de fer, dessinez un circuit en forme d'un rond (deux rails avec les traverses).\n\n\nUtilisez une boucle `for` pour la répétition des traverses.\n"},{"metadata":{"trusted":true},"cell_type":"code","source":"from turtle import *\n# Prénom Nom, classe\n\ndef traverse():\n ...\n\nforward(200)\n\ndone()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"markdown","source":"<h3 style=\"color:teal;background-color:azure;\" > <i class=\"fa fa-pencil\" aria-hidden=\"true\"> </i> Exercice 12</h3>\n\nTriangle de sierpinski\n\n"},{"metadata":{"trusted":true},"cell_type":"code","source":"from turtle import *\n\ndef triangle(l):\n for _ in range(3):\n forward(l)\n left(120)\n\n\n\nx = 50\nfor _ in range(3):\n triangle(x)\n forward(x)\n right(120)\n\ndone()","execution_count":2,"outputs":[{"output_type":"display_data","data":{"image/svg+xml":"<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"640\" height=\"480\" preserveaspectratio=\"xMidYMid meet\" viewbox=\"0 0 640 480\"><animate id=\"af_e406a38e2bf040129671b6c27ef65f5d_0\" attributename=\"opacity\" attributetype=\"CSS\" from=\"1\" to=\"1\" begin=\"0s\" dur=\"1ms\" fill=\"freeze\"></animate><g transform=\"translate(320 240)\"></g><g transform=\"translate(320 240)\"><line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"0\" style=\"stroke: black;stroke-width: 1\"><animate id=\"af_e406a38e2bf040129671b6c27ef65f5d_2\" attributename=\"x2\" attributetype=\"XML\" from=\"0\" to=\"0\" dur=\"1ms\" fill=\"freeze\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_1.end\"></animate><animate attributename=\"y2\" attributetype=\"XML\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_1.end\" from=\"0\" to=\"0\" dur=\"1ms\" fill=\"freeze\"></animate></line><line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"0\" style=\"stroke: black;stroke-width: 1\"><animate id=\"af_e406a38e2bf040129671b6c27ef65f5d_5\" attributename=\"x2\" attributetype=\"XML\" from=\"0\" to=\"50\" dur=\" 0.268s\" fill=\"freeze\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_4.end\"></animate><animate attributename=\"y2\" attributetype=\"XML\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_4.end\" from=\"0\" to=\"0\" dur=\" 0.268s\" fill=\"freeze\"></animate></line><line x1=\"50\" y1=\"0\" x2=\"50\" y2=\"0\" style=\"stroke: black;stroke-width: 1\"><animate id=\"af_e406a38e2bf040129671b6c27ef65f5d_7\" attributename=\"x2\" attributetype=\"XML\" from=\"50\" to=\"25.00000000000001\" dur=\" 0.268s\" fill=\"freeze\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_6.end\"></animate><animate attributename=\"y2\" attributetype=\"XML\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_6.end\" from=\"0\" to=\"-43.30127018922194\" dur=\" 0.268s\" fill=\"freeze\"></animate></line><line x1=\"25.00000000000001\" y1=\"-43.30127018922194\" x2=\"25.00000000000001\" y2=\"-43.30127018922194\" style=\"stroke: black;stroke-width: 1\"><animate id=\"af_e406a38e2bf040129671b6c27ef65f5d_9\" attributename=\"x2\" attributetype=\"XML\" from=\"25.00000000000001\" to=\"-1.0658141036401503e-14\" dur=\" 0.268s\" fill=\"freeze\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_8.end\"></animate><animate attributename=\"y2\" attributetype=\"XML\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_8.end\" from=\"-43.30127018922194\" to=\"-1.4210854715202004e-14\" dur=\" 0.268s\" fill=\"freeze\"></animate></line><line x1=\"-1.0658141036401503e-14\" y1=\"-1.4210854715202004e-14\" x2=\"-1.0658141036401503e-14\" y2=\"-1.4210854715202004e-14\" style=\"stroke: black;stroke-width: 1\"><animate id=\"af_e406a38e2bf040129671b6c27ef65f5d_11\" attributename=\"x2\" attributetype=\"XML\" from=\"-1.0658141036401503e-14\" to=\"49.999999999999986\" dur=\" 0.268s\" fill=\"freeze\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_10.end\"></animate><animate attributename=\"y2\" attributetype=\"XML\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_10.end\" from=\"-1.4210854715202004e-14\" to=\"-1.9643867237284715e-15\" dur=\" 0.268s\" fill=\"freeze\"></animate></line><line x1=\"49.999999999999986\" y1=\"-1.9643867237284715e-15\" x2=\"49.999999999999986\" y2=\"-1.9643867237284715e-15\" style=\"stroke: black;stroke-width: 1\"><animate id=\"af_e406a38e2bf040129671b6c27ef65f5d_13\" attributename=\"x2\" attributetype=\"XML\" from=\"49.999999999999986\" to=\"24.999999999999964\" dur=\" 0.268s\" fill=\"freeze\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_12.end\"></animate><animate attributename=\"y2\" attributetype=\"XML\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_12.end\" from=\"-1.9643867237284715e-15\" to=\"43.301270189221924\" dur=\" 0.268s\" fill=\"freeze\"></animate></line><line x1=\"24.999999999999964\" y1=\"43.301270189221924\" x2=\"24.999999999999964\" y2=\"43.301270189221924\" style=\"stroke: black;stroke-width: 1\"><animate id=\"af_e406a38e2bf040129671b6c27ef65f5d_15\" attributename=\"x2\" attributetype=\"XML\" from=\"24.999999999999964\" to=\"74.99999999999997\" dur=\" 0.268s\" fill=\"freeze\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_14.end\"></animate><animate attributename=\"y2\" attributetype=\"XML\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_14.end\" from=\"43.301270189221924\" to=\"43.30127018922194\" dur=\" 0.268s\" fill=\"freeze\"></animate></line><line x1=\"74.99999999999997\" y1=\"43.30127018922194\" x2=\"74.99999999999997\" y2=\"43.30127018922194\" style=\"stroke: black;stroke-width: 1\"><animate id=\"af_e406a38e2bf040129671b6c27ef65f5d_17\" attributename=\"x2\" attributetype=\"XML\" from=\"74.99999999999997\" to=\"50.000000000000014\" dur=\" 0.268s\" fill=\"freeze\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_16.end\"></animate><animate attributename=\"y2\" attributetype=\"XML\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_16.end\" from=\"43.30127018922194\" to=\"-2.1316282072803006e-14\" dur=\" 0.268s\" fill=\"freeze\"></animate></line><line x1=\"50.000000000000014\" y1=\"-2.1316282072803006e-14\" x2=\"50.000000000000014\" y2=\"-2.1316282072803006e-14\" style=\"stroke: black;stroke-width: 1\"><animate id=\"af_e406a38e2bf040129671b6c27ef65f5d_19\" attributename=\"x2\" attributetype=\"XML\" from=\"50.000000000000014\" to=\"25.00000000000002\" dur=\" 0.268s\" fill=\"freeze\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_18.end\"></animate><animate attributename=\"y2\" attributetype=\"XML\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_18.end\" from=\"-2.1316282072803006e-14\" to=\"43.30127018922192\" dur=\" 0.268s\" fill=\"freeze\"></animate></line><line x1=\"25.00000000000002\" y1=\"43.30127018922192\" x2=\"25.00000000000002\" y2=\"43.30127018922192\" style=\"stroke: black;stroke-width: 1\"><animate id=\"af_e406a38e2bf040129671b6c27ef65f5d_21\" attributename=\"x2\" attributetype=\"XML\" from=\"25.00000000000002\" to=\"6.039613253960852e-14\" dur=\" 0.268s\" fill=\"freeze\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_20.end\"></animate><animate attributename=\"y2\" attributetype=\"XML\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_20.end\" from=\"43.30127018922192\" to=\"-4.263256414560601e-14\" dur=\" 0.268s\" fill=\"freeze\"></animate></line><line x1=\"6.039613253960852e-14\" y1=\"-4.263256414560601e-14\" x2=\"6.039613253960852e-14\" y2=\"-4.263256414560601e-14\" style=\"stroke: black;stroke-width: 1\"><animate id=\"af_e406a38e2bf040129671b6c27ef65f5d_23\" attributename=\"x2\" attributetype=\"XML\" from=\"6.039613253960852e-14\" to=\"-24.999999999999932\" dur=\" 0.268s\" fill=\"freeze\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_22.end\"></animate><animate attributename=\"y2\" attributetype=\"XML\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_22.end\" from=\"-4.263256414560601e-14\" to=\"43.301270189221896\" dur=\" 0.268s\" fill=\"freeze\"></animate></line><line x1=\"-24.999999999999932\" y1=\"43.301270189221896\" x2=\"-24.999999999999932\" y2=\"43.301270189221896\" style=\"stroke: black;stroke-width: 1\"><animate id=\"af_e406a38e2bf040129671b6c27ef65f5d_25\" attributename=\"x2\" attributetype=\"XML\" from=\"-24.999999999999932\" to=\"25.000000000000068\" dur=\" 0.268s\" fill=\"freeze\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_24.end\"></animate><animate attributename=\"y2\" attributetype=\"XML\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_24.end\" from=\"43.301270189221896\" to=\"43.30127018922192\" dur=\" 0.268s\" fill=\"freeze\"></animate></line><line x1=\"25.000000000000068\" y1=\"43.30127018922192\" x2=\"25.000000000000068\" y2=\"43.30127018922192\" style=\"stroke: black;stroke-width: 1\"><animate id=\"af_e406a38e2bf040129671b6c27ef65f5d_27\" attributename=\"x2\" attributetype=\"XML\" from=\"25.000000000000068\" to=\"3.907985046680551e-14\" dur=\" 0.268s\" fill=\"freeze\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_26.end\"></animate><animate attributename=\"y2\" attributetype=\"XML\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_26.end\" from=\"43.30127018922192\" to=\"0\" dur=\" 0.268s\" fill=\"freeze\"></animate></line></g><g transform=\"translate(320 240)\"></g><g transform=\"translate(320 240)\"><polygon points=\"0,16 -2,14 -1,10 -4,7 -7,9 -9,8 -6,5 -7,1 -5,-3 -8,-6 -6,-8 -4,-5 0,-7 4,-5 6,-8 8,-6 5,-3 7,1 6,5 9,8 7,9 4,7 1,10 2,14\" stroke=\"black\" fill=\"black\" stroke-width=\"1\" opacity=\"0\"><animate id=\"af_e406a38e2bf040129671b6c27ef65f5d_1\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_0.end\" dur=\"1ms\" fill=\"freeze\" attributename=\"opacity\" attributetype=\"XML\" from=\"0\" to=\"1\"></animate><animateMotion begin=\"af_e406a38e2bf040129671b6c27ef65f5d_2.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateTransform attributename=\"transform\" id=\"af_e406a38e2bf040129671b6c27ef65f5d_3\" type=\"rotate\" from=\"0,0,0\" to=\"0.0,0,0\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_2.end\" dur=\"1ms\" fill=\"freeze\"></animateTransform><animateMotion begin=\"af_e406a38e2bf040129671b6c27ef65f5d_3.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateTransform attributename=\"transform\" id=\"af_e406a38e2bf040129671b6c27ef65f5d_4\" type=\"rotate\" from=\"-90.0,0,0\" to=\"-90.0,0,0\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_3.end\" dur=\"1ms\" fill=\"freeze\"></animateTransform><animateMotion begin=\"af_e406a38e2bf040129671b6c27ef65f5d_4.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateMotion from=\"0.0,-0.0\" to=\"50.0,-0.0\" dur=\" 0.268s\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_4.end\" fill=\"freeze\"></animateMotion><animateMotion begin=\"af_e406a38e2bf040129671b6c27ef65f5d_5.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateTransform attributename=\"transform\" id=\"af_e406a38e2bf040129671b6c27ef65f5d_6\" type=\"rotate\" from=\"-90.0,0,0\" to=\"-210.0,0,0\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_5.end\" dur=\" 0.111s\" fill=\"freeze\"></animateTransform><animateMotion begin=\"af_e406a38e2bf040129671b6c27ef65f5d_6.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateMotion from=\"50.0,-0.0\" to=\"25.00000000000001,-43.30127018922194\" dur=\" 0.268s\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_6.end\" fill=\"freeze\"></animateMotion><animateMotion begin=\"af_e406a38e2bf040129671b6c27ef65f5d_7.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateTransform attributename=\"transform\" id=\"af_e406a38e2bf040129671b6c27ef65f5d_8\" type=\"rotate\" from=\"-210.0,0,0\" to=\"-330.0,0,0\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_7.end\" dur=\" 0.111s\" fill=\"freeze\"></animateTransform><animateMotion begin=\"af_e406a38e2bf040129671b6c27ef65f5d_8.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateMotion from=\"25.00000000000001,-43.30127018922194\" to=\"-1.0658141036401503e-14,-1.4210854715202004e-14\" dur=\" 0.268s\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_8.end\" fill=\"freeze\"></animateMotion><animateMotion begin=\"af_e406a38e2bf040129671b6c27ef65f5d_9.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateTransform attributename=\"transform\" id=\"af_e406a38e2bf040129671b6c27ef65f5d_10\" type=\"rotate\" from=\"-330.0,0,0\" to=\"-450.0,0,0\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_9.end\" dur=\" 0.111s\" fill=\"freeze\"></animateTransform><animateMotion begin=\"af_e406a38e2bf040129671b6c27ef65f5d_10.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateMotion from=\"-1.0658141036401503e-14,-1.4210854715202004e-14\" to=\"49.999999999999986,-1.9643867237284715e-15\" dur=\" 0.268s\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_10.end\" fill=\"freeze\"></animateMotion><animateMotion begin=\"af_e406a38e2bf040129671b6c27ef65f5d_11.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateTransform attributename=\"transform\" id=\"af_e406a38e2bf040129671b6c27ef65f5d_12\" type=\"rotate\" from=\"-450.0,0,0\" to=\"-330.0,0,0\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_11.end\" dur=\" 0.111s\" fill=\"freeze\"></animateTransform><animateMotion begin=\"af_e406a38e2bf040129671b6c27ef65f5d_12.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateMotion from=\"49.999999999999986,-1.9643867237284715e-15\" to=\"24.999999999999964,43.301270189221924\" dur=\" 0.268s\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_12.end\" fill=\"freeze\"></animateMotion><animateMotion begin=\"af_e406a38e2bf040129671b6c27ef65f5d_13.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateTransform attributename=\"transform\" id=\"af_e406a38e2bf040129671b6c27ef65f5d_14\" type=\"rotate\" from=\"-330.0,0,0\" to=\"-450.0,0,0\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_13.end\" dur=\" 0.111s\" fill=\"freeze\"></animateTransform><animateMotion begin=\"af_e406a38e2bf040129671b6c27ef65f5d_14.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateMotion from=\"24.999999999999964,43.301270189221924\" to=\"74.99999999999997,43.30127018922194\" dur=\" 0.268s\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_14.end\" fill=\"freeze\"></animateMotion><animateMotion begin=\"af_e406a38e2bf040129671b6c27ef65f5d_15.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateTransform attributename=\"transform\" id=\"af_e406a38e2bf040129671b6c27ef65f5d_16\" type=\"rotate\" from=\"-450.0,0,0\" to=\"-570.0,0,0\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_15.end\" dur=\" 0.111s\" fill=\"freeze\"></animateTransform><animateMotion begin=\"af_e406a38e2bf040129671b6c27ef65f5d_16.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateMotion from=\"74.99999999999997,43.30127018922194\" to=\"50.000000000000014,-2.1316282072803006e-14\" dur=\" 0.268s\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_16.end\" fill=\"freeze\"></animateMotion><animateMotion begin=\"af_e406a38e2bf040129671b6c27ef65f5d_17.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateTransform attributename=\"transform\" id=\"af_e406a38e2bf040129671b6c27ef65f5d_18\" type=\"rotate\" from=\"-570.0,0,0\" to=\"-690.0,0,0\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_17.end\" dur=\" 0.111s\" fill=\"freeze\"></animateTransform><animateMotion begin=\"af_e406a38e2bf040129671b6c27ef65f5d_18.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateMotion from=\"50.000000000000014,-2.1316282072803006e-14\" to=\"25.00000000000002,43.30127018922192\" dur=\" 0.268s\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_18.end\" fill=\"freeze\"></animateMotion><animateMotion begin=\"af_e406a38e2bf040129671b6c27ef65f5d_19.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateTransform attributename=\"transform\" id=\"af_e406a38e2bf040129671b6c27ef65f5d_20\" type=\"rotate\" from=\"-690.0,0,0\" to=\"-570.0,0,0\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_19.end\" dur=\" 0.111s\" fill=\"freeze\"></animateTransform><animateMotion begin=\"af_e406a38e2bf040129671b6c27ef65f5d_20.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateMotion from=\"25.00000000000002,43.30127018922192\" to=\"6.039613253960852e-14,-4.263256414560601e-14\" dur=\" 0.268s\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_20.end\" fill=\"freeze\"></animateMotion><animateMotion begin=\"af_e406a38e2bf040129671b6c27ef65f5d_21.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateTransform attributename=\"transform\" id=\"af_e406a38e2bf040129671b6c27ef65f5d_22\" type=\"rotate\" from=\"-570.0,0,0\" to=\"-690.0,0,0\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_21.end\" dur=\" 0.111s\" fill=\"freeze\"></animateTransform><animateMotion begin=\"af_e406a38e2bf040129671b6c27ef65f5d_22.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateMotion from=\"6.039613253960852e-14,-4.263256414560601e-14\" to=\"-24.999999999999932,43.301270189221896\" dur=\" 0.268s\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_22.end\" fill=\"freeze\"></animateMotion><animateMotion begin=\"af_e406a38e2bf040129671b6c27ef65f5d_23.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateTransform attributename=\"transform\" id=\"af_e406a38e2bf040129671b6c27ef65f5d_24\" type=\"rotate\" from=\"-690.0,0,0\" to=\"-810.0,0,0\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_23.end\" dur=\" 0.111s\" fill=\"freeze\"></animateTransform><animateMotion begin=\"af_e406a38e2bf040129671b6c27ef65f5d_24.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateMotion from=\"-24.999999999999932,43.301270189221896\" to=\"25.000000000000068,43.30127018922192\" dur=\" 0.268s\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_24.end\" fill=\"freeze\"></animateMotion><animateMotion begin=\"af_e406a38e2bf040129671b6c27ef65f5d_25.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateTransform attributename=\"transform\" id=\"af_e406a38e2bf040129671b6c27ef65f5d_26\" type=\"rotate\" from=\"-810.0,0,0\" to=\"-930.0,0,0\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_25.end\" dur=\" 0.111s\" fill=\"freeze\"></animateTransform><animateMotion begin=\"af_e406a38e2bf040129671b6c27ef65f5d_26.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateMotion from=\"25.000000000000068,43.30127018922192\" to=\"3.907985046680551e-14,-0.0\" dur=\" 0.268s\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_26.end\" fill=\"freeze\"></animateMotion><animateMotion begin=\"af_e406a38e2bf040129671b6c27ef65f5d_27.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateTransform attributename=\"transform\" id=\"af_e406a38e2bf040129671b6c27ef65f5d_28\" type=\"rotate\" from=\"-930.0,0,0\" to=\"-810.0,0,0\" begin=\"af_e406a38e2bf040129671b6c27ef65f5d_27.end\" dur=\" 0.111s\" fill=\"freeze\"></animateTransform></polygon></g></svg>"},"metadata":{}}]},{"metadata":{"trusted":true},"cell_type":"code","source":"# A corriger !!!\n\nfrom turtle import *\n\ndef triangle(l):\n for _ in range(3):\n forward(l)\n left(120)\n\ndef sierpinski(l, n):\n if n ==0:\n triangle(l)\n else:\n for _ in range(3):\n sierpinski(l/3, n-1)\n forward(l/3)\n right(120) \n\nspeed(10)\nsierpinski(200, 1)\n\n\ndone()","execution_count":7,"outputs":[{"output_type":"display_data","data":{"image/svg+xml":"<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"640\" height=\"480\" preserveaspectratio=\"xMidYMid meet\" viewbox=\"0 0 640 480\"><animate id=\"af_4a120c6550f842cd9a26f33bb02d4cac_0\" attributename=\"opacity\" attributetype=\"CSS\" from=\"1\" to=\"1\" begin=\"0s\" dur=\"1ms\" fill=\"freeze\"></animate><g transform=\"translate(320 240)\"></g><g transform=\"translate(320 240)\"><line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"0\" style=\"stroke: black;stroke-width: 1\"><animate id=\"af_4a120c6550f842cd9a26f33bb02d4cac_2\" attributename=\"x2\" attributetype=\"XML\" from=\"0\" to=\"0\" dur=\"1ms\" fill=\"freeze\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_1.end\"></animate><animate attributename=\"y2\" attributetype=\"XML\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_1.end\" from=\"0\" to=\"0\" dur=\"1ms\" fill=\"freeze\"></animate></line><line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"0\" style=\"stroke: black;stroke-width: 1\"><animate id=\"af_4a120c6550f842cd9a26f33bb02d4cac_5\" attributename=\"x2\" attributetype=\"XML\" from=\"0\" to=\"66.66666666666667\" dur=\" 0.084s\" fill=\"freeze\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_4.end\"></animate><animate attributename=\"y2\" attributetype=\"XML\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_4.end\" from=\"0\" to=\"0\" dur=\" 0.084s\" fill=\"freeze\"></animate></line><line x1=\"66.66666666666667\" y1=\"0\" x2=\"66.66666666666667\" y2=\"0\" style=\"stroke: black;stroke-width: 1\"><animate id=\"af_4a120c6550f842cd9a26f33bb02d4cac_7\" attributename=\"x2\" attributetype=\"XML\" from=\"66.66666666666667\" to=\"33.33333333333335\" dur=\" 0.084s\" fill=\"freeze\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_6.end\"></animate><animate attributename=\"y2\" attributetype=\"XML\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_6.end\" from=\"0\" to=\"-57.73502691896258\" dur=\" 0.084s\" fill=\"freeze\"></animate></line><line x1=\"33.33333333333335\" y1=\"-57.73502691896258\" x2=\"33.33333333333335\" y2=\"-57.73502691896258\" style=\"stroke: black;stroke-width: 1\"><animate id=\"af_4a120c6550f842cd9a26f33bb02d4cac_9\" attributename=\"x2\" attributetype=\"XML\" from=\"33.33333333333335\" to=\"-1.4210854715202004e-14\" dur=\" 0.084s\" fill=\"freeze\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_8.end\"></animate><animate attributename=\"y2\" attributetype=\"XML\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_8.end\" from=\"-57.73502691896258\" to=\"-1.4210854715202004e-14\" dur=\" 0.084s\" fill=\"freeze\"></animate></line><line x1=\"-1.4210854715202004e-14\" y1=\"-1.4210854715202004e-14\" x2=\"-1.4210854715202004e-14\" y2=\"-1.4210854715202004e-14\" style=\"stroke: black;stroke-width: 1\"><animate id=\"af_4a120c6550f842cd9a26f33bb02d4cac_11\" attributename=\"x2\" attributetype=\"XML\" from=\"-1.4210854715202004e-14\" to=\"66.66666666666666\" dur=\" 0.084s\" fill=\"freeze\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_10.end\"></animate><animate attributename=\"y2\" attributetype=\"XML\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_10.end\" from=\"-1.4210854715202004e-14\" to=\"2.1177692734293746e-15\" dur=\" 0.084s\" fill=\"freeze\"></animate></line><line x1=\"66.66666666666666\" y1=\"2.1177692734293746e-15\" x2=\"66.66666666666666\" y2=\"2.1177692734293746e-15\" style=\"stroke: black;stroke-width: 1\"><animate id=\"af_4a120c6550f842cd9a26f33bb02d4cac_13\" attributename=\"x2\" attributetype=\"XML\" from=\"66.66666666666666\" to=\"33.33333333333329\" dur=\" 0.084s\" fill=\"freeze\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_12.end\"></animate><animate attributename=\"y2\" attributetype=\"XML\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_12.end\" from=\"2.1177692734293746e-15\" to=\"57.73502691896257\" dur=\" 0.084s\" fill=\"freeze\"></animate></line><line x1=\"33.33333333333329\" y1=\"57.73502691896257\" x2=\"33.33333333333329\" y2=\"57.73502691896257\" style=\"stroke: black;stroke-width: 1\"><animate id=\"af_4a120c6550f842cd9a26f33bb02d4cac_15\" attributename=\"x2\" attributetype=\"XML\" from=\"33.33333333333329\" to=\"99.99999999999997\" dur=\" 0.084s\" fill=\"freeze\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_14.end\"></animate><animate attributename=\"y2\" attributetype=\"XML\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_14.end\" from=\"57.73502691896257\" to=\"57.73502691896258\" dur=\" 0.084s\" fill=\"freeze\"></animate></line><line x1=\"99.99999999999997\" y1=\"57.73502691896258\" x2=\"99.99999999999997\" y2=\"57.73502691896258\" style=\"stroke: black;stroke-width: 1\"><animate id=\"af_4a120c6550f842cd9a26f33bb02d4cac_17\" attributename=\"x2\" attributetype=\"XML\" from=\"99.99999999999997\" to=\"66.66666666666669\" dur=\" 0.084s\" fill=\"freeze\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_16.end\"></animate><animate attributename=\"y2\" attributetype=\"XML\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_16.end\" from=\"57.73502691896258\" to=\"-3.552713678800501e-14\" dur=\" 0.084s\" fill=\"freeze\"></animate></line><line x1=\"66.66666666666669\" y1=\"-3.552713678800501e-14\" x2=\"66.66666666666669\" y2=\"-3.552713678800501e-14\" style=\"stroke: black;stroke-width: 1\"><animate id=\"af_4a120c6550f842cd9a26f33bb02d4cac_19\" attributename=\"x2\" attributetype=\"XML\" from=\"66.66666666666669\" to=\"33.333333333333364\" dur=\" 0.084s\" fill=\"freeze\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_18.end\"></animate><animate attributename=\"y2\" attributetype=\"XML\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_18.end\" from=\"-3.552713678800501e-14\" to=\"57.73502691896255\" dur=\" 0.084s\" fill=\"freeze\"></animate></line><line x1=\"33.333333333333364\" y1=\"57.73502691896255\" x2=\"33.333333333333364\" y2=\"57.73502691896255\" style=\"stroke: black;stroke-width: 1\"><animate id=\"af_4a120c6550f842cd9a26f33bb02d4cac_21\" attributename=\"x2\" attributetype=\"XML\" from=\"33.333333333333364\" to=\"7.815970093361102e-14\" dur=\" 0.084s\" fill=\"freeze\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_20.end\"></animate><animate attributename=\"y2\" attributetype=\"XML\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_20.end\" from=\"57.73502691896255\" to=\"-7.105427357601002e-14\" dur=\" 0.084s\" fill=\"freeze\"></animate></line><line x1=\"7.815970093361102e-14\" y1=\"-7.105427357601002e-14\" x2=\"7.815970093361102e-14\" y2=\"-7.105427357601002e-14\" style=\"stroke: black;stroke-width: 1\"><animate id=\"af_4a120c6550f842cd9a26f33bb02d4cac_23\" attributename=\"x2\" attributetype=\"XML\" from=\"7.815970093361102e-14\" to=\"-33.33333333333324\" dur=\" 0.084s\" fill=\"freeze\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_22.end\"></animate><animate attributename=\"y2\" attributetype=\"XML\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_22.end\" from=\"-7.105427357601002e-14\" to=\"57.73502691896251\" dur=\" 0.084s\" fill=\"freeze\"></animate></line><line x1=\"-33.33333333333324\" y1=\"57.73502691896251\" x2=\"-33.33333333333324\" y2=\"57.73502691896251\" style=\"stroke: black;stroke-width: 1\"><animate id=\"af_4a120c6550f842cd9a26f33bb02d4cac_25\" attributename=\"x2\" attributetype=\"XML\" from=\"-33.33333333333324\" to=\"33.33333333333343\" dur=\" 0.084s\" fill=\"freeze\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_24.end\"></animate><animate attributename=\"y2\" attributetype=\"XML\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_24.end\" from=\"57.73502691896251\" to=\"57.73502691896255\" dur=\" 0.084s\" fill=\"freeze\"></animate></line><line x1=\"33.33333333333343\" y1=\"57.73502691896255\" x2=\"33.33333333333343\" y2=\"57.73502691896255\" style=\"stroke: black;stroke-width: 1\"><animate id=\"af_4a120c6550f842cd9a26f33bb02d4cac_27\" attributename=\"x2\" attributetype=\"XML\" from=\"33.33333333333343\" to=\"5.684341886080802e-14\" dur=\" 0.084s\" fill=\"freeze\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_26.end\"></animate><animate attributename=\"y2\" attributetype=\"XML\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_26.end\" from=\"57.73502691896255\" to=\"-1.4210854715202004e-14\" dur=\" 0.084s\" fill=\"freeze\"></animate></line></g><g transform=\"translate(320 240)\"></g><g transform=\"translate(320 240)\"><polygon points=\"0,16 -2,14 -1,10 -4,7 -7,9 -9,8 -6,5 -7,1 -5,-3 -8,-6 -6,-8 -4,-5 0,-7 4,-5 6,-8 8,-6 5,-3 7,1 6,5 9,8 7,9 4,7 1,10 2,14\" stroke=\"black\" fill=\"black\" stroke-width=\"1\" opacity=\"0\"><animate id=\"af_4a120c6550f842cd9a26f33bb02d4cac_1\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_0.end\" dur=\"1ms\" fill=\"freeze\" attributename=\"opacity\" attributetype=\"XML\" from=\"0\" to=\"1\"></animate><animateMotion begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_2.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateTransform attributename=\"transform\" id=\"af_4a120c6550f842cd9a26f33bb02d4cac_3\" type=\"rotate\" from=\"0,0,0\" to=\"0.0,0,0\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_2.end\" dur=\"1ms\" fill=\"freeze\"></animateTransform><animateMotion begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_3.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateTransform attributename=\"transform\" id=\"af_4a120c6550f842cd9a26f33bb02d4cac_4\" type=\"rotate\" from=\"-90.0,0,0\" to=\"-90.0,0,0\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_3.end\" dur=\"1ms\" fill=\"freeze\"></animateTransform><animateMotion begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_4.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateMotion from=\"0.0,-0.0\" to=\"66.66666666666667,-0.0\" dur=\" 0.084s\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_4.end\" fill=\"freeze\"></animateMotion><animateMotion begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_5.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateTransform attributename=\"transform\" id=\"af_4a120c6550f842cd9a26f33bb02d4cac_6\" type=\"rotate\" from=\"-90.0,0,0\" to=\"-210.0,0,0\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_5.end\" dur=\" 0.033s\" fill=\"freeze\"></animateTransform><animateMotion begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_6.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateMotion from=\"66.66666666666667,-0.0\" to=\"33.33333333333335,-57.73502691896258\" dur=\" 0.084s\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_6.end\" fill=\"freeze\"></animateMotion><animateMotion begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_7.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateTransform attributename=\"transform\" id=\"af_4a120c6550f842cd9a26f33bb02d4cac_8\" type=\"rotate\" from=\"-210.0,0,0\" to=\"-330.0,0,0\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_7.end\" dur=\" 0.033s\" fill=\"freeze\"></animateTransform><animateMotion begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_8.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateMotion from=\"33.33333333333335,-57.73502691896258\" to=\"-1.4210854715202004e-14,-1.4210854715202004e-14\" dur=\" 0.084s\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_8.end\" fill=\"freeze\"></animateMotion><animateMotion begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_9.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateTransform attributename=\"transform\" id=\"af_4a120c6550f842cd9a26f33bb02d4cac_10\" type=\"rotate\" from=\"-330.0,0,0\" to=\"-450.0,0,0\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_9.end\" dur=\" 0.033s\" fill=\"freeze\"></animateTransform><animateMotion begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_10.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateMotion from=\"-1.4210854715202004e-14,-1.4210854715202004e-14\" to=\"66.66666666666666,2.1177692734293746e-15\" dur=\" 0.084s\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_10.end\" fill=\"freeze\"></animateMotion><animateMotion begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_11.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateTransform attributename=\"transform\" id=\"af_4a120c6550f842cd9a26f33bb02d4cac_12\" type=\"rotate\" from=\"-450.0,0,0\" to=\"-330.0,0,0\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_11.end\" dur=\" 0.033s\" fill=\"freeze\"></animateTransform><animateMotion begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_12.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateMotion from=\"66.66666666666666,2.1177692734293746e-15\" to=\"33.33333333333329,57.73502691896257\" dur=\" 0.084s\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_12.end\" fill=\"freeze\"></animateMotion><animateMotion begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_13.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateTransform attributename=\"transform\" id=\"af_4a120c6550f842cd9a26f33bb02d4cac_14\" type=\"rotate\" from=\"-330.0,0,0\" to=\"-450.0,0,0\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_13.end\" dur=\" 0.033s\" fill=\"freeze\"></animateTransform><animateMotion begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_14.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateMotion from=\"33.33333333333329,57.73502691896257\" to=\"99.99999999999997,57.73502691896258\" dur=\" 0.084s\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_14.end\" fill=\"freeze\"></animateMotion><animateMotion begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_15.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateTransform attributename=\"transform\" id=\"af_4a120c6550f842cd9a26f33bb02d4cac_16\" type=\"rotate\" from=\"-450.0,0,0\" to=\"-570.0,0,0\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_15.end\" dur=\" 0.033s\" fill=\"freeze\"></animateTransform><animateMotion begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_16.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateMotion from=\"99.99999999999997,57.73502691896258\" to=\"66.66666666666669,-3.552713678800501e-14\" dur=\" 0.084s\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_16.end\" fill=\"freeze\"></animateMotion><animateMotion begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_17.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateTransform attributename=\"transform\" id=\"af_4a120c6550f842cd9a26f33bb02d4cac_18\" type=\"rotate\" from=\"-570.0,0,0\" to=\"-690.0,0,0\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_17.end\" dur=\" 0.033s\" fill=\"freeze\"></animateTransform><animateMotion begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_18.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateMotion from=\"66.66666666666669,-3.552713678800501e-14\" to=\"33.333333333333364,57.73502691896255\" dur=\" 0.084s\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_18.end\" fill=\"freeze\"></animateMotion><animateMotion begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_19.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateTransform attributename=\"transform\" id=\"af_4a120c6550f842cd9a26f33bb02d4cac_20\" type=\"rotate\" from=\"-690.0,0,0\" to=\"-570.0,0,0\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_19.end\" dur=\" 0.033s\" fill=\"freeze\"></animateTransform><animateMotion begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_20.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateMotion from=\"33.333333333333364,57.73502691896255\" to=\"7.815970093361102e-14,-7.105427357601002e-14\" dur=\" 0.084s\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_20.end\" fill=\"freeze\"></animateMotion><animateMotion begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_21.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateTransform attributename=\"transform\" id=\"af_4a120c6550f842cd9a26f33bb02d4cac_22\" type=\"rotate\" from=\"-570.0,0,0\" to=\"-690.0,0,0\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_21.end\" dur=\" 0.033s\" fill=\"freeze\"></animateTransform><animateMotion begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_22.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateMotion from=\"7.815970093361102e-14,-7.105427357601002e-14\" to=\"-33.33333333333324,57.73502691896251\" dur=\" 0.084s\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_22.end\" fill=\"freeze\"></animateMotion><animateMotion begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_23.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateTransform attributename=\"transform\" id=\"af_4a120c6550f842cd9a26f33bb02d4cac_24\" type=\"rotate\" from=\"-690.0,0,0\" to=\"-810.0,0,0\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_23.end\" dur=\" 0.033s\" fill=\"freeze\"></animateTransform><animateMotion begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_24.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateMotion from=\"-33.33333333333324,57.73502691896251\" to=\"33.33333333333343,57.73502691896255\" dur=\" 0.084s\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_24.end\" fill=\"freeze\"></animateMotion><animateMotion begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_25.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateTransform attributename=\"transform\" id=\"af_4a120c6550f842cd9a26f33bb02d4cac_26\" type=\"rotate\" from=\"-810.0,0,0\" to=\"-930.0,0,0\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_25.end\" dur=\" 0.033s\" fill=\"freeze\"></animateTransform><animateMotion begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_26.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateMotion from=\"33.33333333333343,57.73502691896255\" to=\"5.684341886080802e-14,-1.4210854715202004e-14\" dur=\" 0.084s\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_26.end\" fill=\"freeze\"></animateMotion><animateMotion begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_27.end\" dur=\"1ms\" fill=\"remove\"></animateMotion><animateTransform attributename=\"transform\" id=\"af_4a120c6550f842cd9a26f33bb02d4cac_28\" type=\"rotate\" from=\"-930.0,0,0\" to=\"-810.0,0,0\" begin=\"af_4a120c6550f842cd9a26f33bb02d4cac_27.end\" dur=\" 0.033s\" fill=\"freeze\"></animateTransform></polygon></g></svg>"},"metadata":{}}]},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"name":"python3","display_name":"Python 3","language":"python"}},"nbformat":4,"nbformat_minor":2} \ No newline at end of file diff --git a/Notebooks/imgs_chap3/carres_tournant.png b/Notebooks/imgs_chap3/carres_tournant.png new file mode 100644 index 0000000000000000000000000000000000000000..289af0d01277c1262b09d686744ccd8bc0fc6c43 Binary files /dev/null and b/Notebooks/imgs_chap3/carres_tournant.png differ