标签:http alt war nbsp 方式 i+1 image blog 分享
问题:
1.画五角星
代码如下:
import turtle
def star(i):
turtle.forward(50)
turtle.right(144)
for i in range(5):
star(i)
运行结果:
2.画同心圆
代码如下:
import turtle
def concentric(i):
turtle.up()
turtle.goto(0,-20*(i+1))
turtle.down()
turtle.circle(20*(i+1))
for i in range(5):
concentric(i)
运行结果:
3.画太阳花
代码如下:
import turtle
turtle.color(‘red‘,‘yellow‘)
turtle.begin_fill()
def flower(x,y):
turtle.forward(x)
turtle.left(y)
while True:
flower(200,165)
if(abs(turtle.pos()))<1:
break
turtle.end_fill()
turtle.done()
运行结果:
4,.画五个角星
代码如下:
import turtle
turtle.color(‘yellow‘)
turtle.bgcolor(‘red‘)
def DrawStar(x,y,a,b):
turtle.begin_fill()
turtle.up()
turtle.goto(x,y)
for i in range(5):
turtle.forward(a)
turtle.right(b)
turtle.end_fill()
DrawStar(-250,75,100,144)
DrawStar(-100,150,50,144)
DrawStar(-80,80,50,144)
DrawStar(-75,23,50,144)
DrawStar(-100,-35,50,144)
运行结果:
标签:http alt war nbsp 方式 i+1 image blog 分享
原文地址:http://www.cnblogs.com/decadeyu/p/7509808.html