
September 26th, 2012, 06:47 AM
|
|
Registered User
|
|
Join Date: Sep 2012
Posts: 2
Time spent in forums: 34 m 47 sec
Reputation Power: 0
|
|
|
Python programming - turtleworld
Hello.. im a beginner at python
I want to draw a sierpenski triangle with depth 5.
Can someone help me please? So far ive drawed a triangle..
I know i have to use recursive loops but i find this hard to understand  .. my idea was to start with the little trinangle and go out to bigger triangles and so on.
so far ive have made:
from swampy.TurtleWorld import *
angle = 60
def triangle(t, length, n):
for i in range(3):
fd(t, length)
lt(t, 180/n)
lt(t, 180/n)
def depth(n):
if n == 0:
return
else:
triangle()
depth(n-1)
world = TurtleWorld()
bob = Turtle()
bob.delay = 0.1
triangle(bob, 10, 60)
wait_for_user()
|