GFT2009_2010
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Python language

Go down

Python language Empty Python language

Post  abed.oubari Wed Mar 27, 2019 4:43 am

A turtle is available as standard under Python. It is not very fast, even for a turtle, but can make interesting figures.

Here's how to use the Python turtle module, in interactive mode (with Idle for example). The complete documentation is here: turtle.html

Example 01:


import turtle as tu

tu.fd(50)
tu.rt(90)
tu.fd(50)
tu.reset()
tu.speed(0)
for i in range(6) :
 tu.fd(100)
 tu.rt(360/6)



Example 02:

import turtle as tu
def flocon(l,n) :
   if n==0 : tu.fd(l)
   else :
       flocon(l/3,n-1)
       tu.lt(60)
       flocon(l/3,n-1)
       tu.right(120)
       flocon(l/3,n-1)
       tu.lt(60)
       flocon(l/3,n-1)

#tu.clearscreen()
#tu.speed(0)
#tu.tracer(5,0)
flocon(243,1)
tu.update()
tu.penup()
tu.back(243)
tu.pendown()

abed.oubari
abed.oubari
Admin

Posts : 77
Join date : 2010-02-25
Age : 45
Location : Morocco

https://gft2009.forumactif.com

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum