Advertisement
AntonioVillanueva

Création d'un pentagone avec le module tortue et Python

Mar 12th, 2019
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. # importation des modules
  4. import turtle
  5. import math
  6.  
  7. def  position(angle,rayon):
  8.     """
  9.         retourne un point x,y depuis un angle et un rayon x->cos y->sin
  10.         Entrée :un angle et un rayon
  11.         Résultat :(x,y) la projection du cosinus en X ,et du sinus en Y
  12.     """
  13.     return ( (round (math.cos( math.radians(angle))*rayon )),
  14.      round ( (math.sin (math.radians(angle)))*rayon))
  15.  
  16. def pentagone(rayon):
  17.     angle=90
  18.  
  19.     #premier point ...
  20.     turtle.up()
  21.     turtle.goto(0,0)
  22.     turtle.down()
  23.    
  24.     while (angle<=360+90 ):#Jusqu'à ce qu'il revienne à 90 °
  25.         turtle.delay(200)#retard pour pouvoir voir le ralenti
  26.         turtle.goto(position (angle,rayon))
  27.         angle+=72 #angle pentagone 72°
  28.  
  29. pentagone(100)
  30. turtle.done()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement