He must not be aware of repl.it/languages/python_turtle -- makes life so simple. With that in mind, here's his draw() example :
import turtle
def draw(t, length, n):
if n == 0:
return
angle = 50
t.forward( length*n)
t.left(angle)
draw(t, length, n-1)
t.right( 2*angle)
draw(t, length, n-1)
t.left( angle)
t.back( length*n)
t = turtle.Turtle()
draw( t, 10, 6)
So cute, and an intro to fractals too :)
No comments:
Post a Comment