条件、循环

画五角星

import turtle
turtle.color('yellow')
turtle.bgcolor('red')
turtle.fillcolor('yellow')

turtle.up()
turtle.goto(-230,130)
turtle.down()

turtle.begin_fill()
for i in range(5):
    turtle.forward(100)
    turtle.right(144)
turtle.end_fill()

 

画同心圆

import turtle
for i in range(5):
    turtle.up()
    turtle.goto(0,-20*(i+1))
    turtle.down()
    turtle.circle(20*(i+1))

 

画太阳花

import turtle
turtle.color('yellow','blue')
turtle.begin_fill()
while True:
    turtle.forward(200)
    turtle.left(170)
    if(abs(turtle.pos()))<1:
        break
turtle.end_fill()
done

 

画五个角星

import turtle
turtle.color('yellow')
turtle.bgcolor('red')
turtle.fillcolor('yellow')
def wugoto(x,y):
    turtle.up()
    turtle.goto(x,y)
    turtle.down()
wugoto(-230,130)
turtle.begin_fill()
for i in range(5):
    turtle.forward(100)
    turtle.right(144)
turtle.end_fill()

wugoto(-110,200)
turtle.begin_fill()
for i in range(5):
    turtle.forward(40)
    turtle.left(144)
turtle.end_fill()

wugoto(-75,150)
turtle.begin_fill()
for i in range(5):
    turtle.forward(40)
    turtle.left(144)
turtle.end_fill()

wugoto(-65,90)
turtle.begin_fill()
for i in range(5):
    turtle.forward(40)
    turtle.left(144)
turtle.end_fill()

wugoto(-90,30)
turtle.begin_fill()
for i in range(5):
    turtle.forward(40)
    turtle.left(144)
turtle.end_fill()

 

 

posted on 2017-09-12 14:52  043李庆  阅读(153)  评论(0)    收藏  举报

导航