Python language
Page 1 of 1
Python language
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()
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()
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|