February 2021 0 63 Report
Salut ! Donc ! je dois reproduire ce dessin via python en utilisant turtle. On a ces deux script pour aider :
import turtle

ecran = turtle.Screen()
tortue = turtle.Turtle()
ecran.title('Turtle et liste Version 2')

lstTurtle = [['color',['red','yellow']],['begin_fill',None],['fd',200],['lt',90],
['fd',200],['lt',90],['fd',200],['lt',90],['fd',200],
['end_fill',None],['up',None],['goto',(210,210)],['down',None],
['color',['yellow','red']],['begin_fill',None],['rt',180],
['fd',100],['rt',90],['fd',100],['rt',90],['fd',100],['rt',90],
['fd',100],['end_fill',None]]

for ele in lstTurtle:
cmd = ele[0]
x = ele[1]
if cmd == 'fd':
tortue.fd(x)
elif cmd == 'bk':
tortue.bk(x)
elif cmd == 'lt':
tortue.lt(x)
elif cmd == 'rt':
tortue.rt(x)
elif cmd == 'up':
tortue.up()
elif cmd == 'down':
tortue.down()
elif cmd == 'goto':
tortue.goto(x)
elif cmd == 'begin_fill':
tortue.begin_fill()
elif cmd == 'end_fill':
tortue.end_fill()
elif cmd == 'color':
tortue.color(x[0],x[1])

turtle.done()
turtle.bye()

-----
import turtle #* \label{script1:import}

ecran = turtle.Screen() #* \label{script1:ecran}
tortue = turtle.Turtle() #* \label{script1:tortue}
ecran.title('Turtle et liste Version 1')#* \label{script1:title}

lstTurtle = [['color',['red','yellow']],['begin_fill',None],['fd',200],['lt',90],
['fd',200],['lt',90],['fd',200],['lt',90],['fd',200],['end_fill',None]]

for ele in lstTurtle:
cmd = ele[0]
x = ele[1]
if cmd == 'fd':
tortue.fd(x)
elif cmd == 'lt':
tortue.lt(x)
elif cmd == 'begin_fill':
tortue.begin_fill()
elif cmd == 'end_fill':
tortue.end_fill()
elif cmd == 'color':
tortue.color(x[0],x[1])

turtle.done()
turtle.bye()
Please enter comments
Please enter your name.
Please enter the correct email address.
You must agree before submitting.

Helpful Social

Copyright © 2024 ELIBRARY.TIPS - All rights reserved.