def hangman(t, n, height): """make a vertical line to the given height and a horizontal line at the given height and then return. This is efficient to implement, and turns out to be useful, but it's not so semantically clean.""" stump(t, n * height) fdbk(t, n) lt(t) bk(t, n*height) rt(t)
rt(t, angle) fd(t, r) lt(t, 90+angle) fd(t, 2*y) lt(t, 90+angle) fd(t, r) lt(t, 180-angle) # create the world and bob world = TurtleWorld() bob = Turtle() bob.delay = 0.01 pu(bob) bk(bob, 130) pd(bob) # draw polypies with various number of sides size = 40 draw_pie(bob, 5, size) draw_pie(bob, 6, size) draw_pie(bob, 7, size) draw_pie(bob, 8, size) die(bob) # dump the contents of the campus to the file canvas.eps #world.canvas.dump() wait_for_user()
def fdbk(t, n): """forward and back, ending at the original position""" fd(t, n) bk(t, n)