[Tutor] Problem with turtle

Marco Rompré marcodrompre at gmail.com
Fri Mar 12 18:19:50 CET 2010


The thing is that the teacher wanted us to use a while loop like in the
notes but even in the notes I copied the code and it was not working either.

Now, I'm more on the right track, I am able to draw the forms and the
counter is almost working, the reason I say that is because turtle is doin
what I want it to do but twice and then its bugs.

For example it will trace my 10  red squares with a specific space between
them then it will redraw them all once but all on the same squares like it
would want the trace to be stronger or somehting like that.

Here's my code now:

from turtle import *

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 *
up()
goto(-400,0)

n=0
while n < 10:
    down()                         # abaisser le crayon
    carre(25*n, 'red', 0)            # tracer un carré
    up()
    forward(30*n)
    n=n+1
    #triangle(90, 'blue',0)
    #up()
    #forward(115)

I put the triangle fucntion in comments cause I was trying to make the carré
function working before.


Thank You


-- 
Marc-O. Rompré
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100312/ff54d3cc/attachment-0001.html>


More information about the Tutor mailing list