[Tutor] Problem with turtle
Marco Rompré
marcodrompre at gmail.com
Thu Mar 11 16:11:28 CET 2010
Hi! I am relatively new to python and turtle and I really need your help.
Here what I wanted turtle to do: I created a function named carré which
would draw a square with 3 different parameters (color, size, angle).
I did the same for a function
named triangle that would draw an equilateral triangle with the same
parameters
With the help of these 2
functions I wanted turtle to draw a yellow square then lift my pointer let a
space and then draw a blue triangle five times in a row.
Here's my code: ignore my comments
def carre(taille, couleur, angle):
"fonction qui dessine un carré de taille et de couleur déterminées"
color(couleur)
c=0
while c<4:
left(angle)
forward(taille)
right(90)
c = c+1
def triangle(taille, couleur, angle):
"fonction qui dessine un triangle équilatéral de taille, de couleur et
d'angle déterminés"
color(couleur)
c=0
while c<3:
left(angle)
forward(taille)
right(120)
c = c+1
from dessins_tortue import *
n=0
while n < 10 :
down() # abaisser le crayon
carre(25, 'yellow', 0) # tracer un carré
up()
forward(30)
triangle(90, 'blue',0)
n = n + 1
If I am to vague I wanted to do successfully exercise 7.6 in Gérard Swinnen
tutorial for Python
It was supposed to look like this
--
Marc-O. Rompré
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100311/e7f37970/attachment-0001.html>
More information about the Tutor
mailing list