擅长:python、mysql、java
<pre><code>import turtle
wn = turtle.Screen()
house = turtle.Turtle()
# function table for the turtle (fill up with other functions)
draw = {
'F': house.forward,
'L': house.left,
}
# direction, value
instructions = (
('F', 150),
('L', 90),
('F', 110),
('L', 45),
('F', 110),
('L', 90),
('F', 110),
('L', 45),
('F', 110),
)
for dir, val in instructions:
draw[dir](val) # call each function from the dict with the value
wn.mainloop()
</code></pre>