But he must be ein genius if he can see what his draw program does just by looking at it. Urm... maybe if you worked out the turtle examples in his ch.4 you'd be okay :) (I didn't)
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