标签:ast port hid win war screen .sh code forward
1.用循环画五角星
1 import turtle 2 3 4 turtle.hideturtle() 5 turtle.speed(10) 6 7 turtle.setup(600,400,0,0) 8 turtle.color("yellow") 9 turtle.bgcolor("red") 10 turtle.fillcolor("yellow") 11 12 turtle.up() 13 turtle.goto(-250,75) 14 turtle.down() 15 16 turtle.begin_fill() 17 for i in range(5): 18 turtle.forward(100) 19 turtle.right(144) 20 21 turtle.end_fill()
2.用循环画同心圆
1 from turtle import* 2 for i in range(5): 3 up() 4 goto(0,-20*(i)) 5 down() 6 circle(20*i)
3.用while循环画太阳花
1 from turtle import* 2 3 color(‘red‘,‘blue‘) 4 begin_fill() 5 while True: 6 forward(200) 7 left(170) 8 if (abs(pos()))<1: 9 break 10 end_fill() 11 done(
4.用函数定义画五个五角星
1 import turtle 2 turtle.setup(600,400,0,0) 3 turtle.color("yellow") 4 turtle.bgcolor(‘red‘) 5 turtle.fillcolor("yellow") 6 turtle.up() 7 turtle.goto(-250,75) 8 turtle.down() 9 turtle.begin_fill() 10 for i in range(5): 11 turtle.forward(100) 12 turtle.right(144) 13 turtle.end_fill() 14 15 turtle.up() 16 turtle.goto(-100,-10) 17 turtle.down() 18 turtle.begin_fill() 19 for i in range(5): 20 turtle.forward(50) 21 turtle.left(144) 22 turtle.end_fill() 23 24 turtle.up() 25 turtle.goto(-50,50) 26 turtle.down() 27 turtle.begin_fill() 28 for i in range(5): 29 turtle.forward(50) 30 turtle.right(144) 31 turtle.end_fill() 32 33 turtle.up() 34 turtle.goto(-50,120) 35 turtle.down() 36 turtle.begin_fill() 37 for i in range(5): 38 turtle.forward(50) 39 turtle.right(144) 40 turtle.end_fill() 41 42 turtle.up() 43 turtle.goto(-100,160) 44 turtle.down() 45 turtle.begin_fill() 46 for i in range(5): 47 turtle.forward(50) 48 turtle.left(144) 49 turtle.end_fill() 50 51 turtle.color("red")
5.用函数定义画钻石花瓣的太阳花
1 import turtle 2 3 def draw_diamond(brad): 4 brad.forward(100) 5 brad.right(45) 6 brad.forward(100) 7 brad.right(135) 8 9 def draw_art(): 10 11 window=turtle.Screen() 12 window.bgcolor("purple") 13 14 brad=turtle.Turtle() 15 brad.shape("turtle") 16 brad.color("orange") 17 brad.speed("fastest") 18 19 20 for i in range(0,36): 21 draw_diamond(brad) 22 draw_diamond(brad) 23 brad.left(10) 24 25 brad.right(90) 26 brad.forward(155) 27 brad.color(‘green‘) 28 brad.forward(145) 29 30 window.exitonclick() 31 32 draw_art()
标签:ast port hid win war screen .sh code forward
原文地址:http://www.cnblogs.com/lingg/p/7517497.html