标签:
1 import turtle #allows us to use the turtles library 2 wn = turtle.Screen() #creates a graphics window 3 wn.bgcolor("lightgreen")#set the window background color 4 5 alex = turtle.Turtle() #create a turtle named alex 6 alex.pensize(3) #set the width of her pen 7 alex.color("pink") #make alex pink color is attribute 8 alex.forward(150) #tell alex to move forward by 150 units 9 alex.left(90) #turn by 90 degrees, right is clockwise, left is counter clockwise 10 alex.forward(75) #complete the second side of a rectangle 11 alex.left(90) 12 alex.forward(150) 13 alex.left(90) 14 alex.forward(75) 15 16 tess = turtle.Turtle() 17 tess.color("hotpink") 18 tess.pensize(5) 19 20 tess.forward(150) 21 tess.left(120) 22 tess.forward(150) 23 tess.left(120) 24 tess.forward(150) 25 26 david = turtle.Turtle() 27 david.color("blue") 28 david.pensize(5) 29 30 for i in ["yellow", "red", "purple", "blue"]: 31 david.color(i) 32 david.forward(150) 33 david.left(90) 34 35 wn.exitonclick() #wait for a user click on the canvas
标签:
原文地址:http://www.cnblogs.com/elewei/p/5351199.html