条件、循环、函数定义 练习

1.画五角星

from turtle import*
for i in range(5):
    forward(150)
    right(144)

2.画同心圆

 

from turtle import*
for i in range(5):
    circle(30*(i+1))
    write(10-i)
    up()
    goto(0,-30*(i+1))
    down()

3.画太阳花

from turtle import*
color('yellow','red')
bgcolor('green')
while True:
    forward(180)
    left(165)
    if(abs(pos()))<1:
        break

4.画五个角星

from turtle import*
setup(600,400,0,0)
color('yellow')
bgcolor('red')
fillcolor('yellow')

def wjqgoto(x,y):
    up()
    goto(x,y)
    down()

wjqgoto(-250,75)

begin_fill()

for i in range(5):
    forward(120)
    right(144)
end_fill()

wjqgoto(-120,150)

begin_fill()
for i in range(5):
    forward(60)
    right(144)
end_fill()

wjqgoto(-80,100)

begin_fill()
for i in range(5):
    forward(60)
    right(144)
end_fill()

wjqgoto(-90,35)

begin_fill()
for i in range(5):
    forward(60)
    right(144)
end_fill()

wjqgoto(-120,-25)

begin_fill()
for i in range(5):
    forward(60)
    right(144)
end_fill()

 

posted @ 2017-09-12 13:43  007王俊祺  阅读(151)  评论(0编辑  收藏  举报