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

画五角星

from turtle import*
up()
bgcolor('red')
color('yellow')
down()
begin_fill()
for i in range(5):
    forward(100)
    right(144)
end_fill()

 

画同心圆

import turtle

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

 

画太阳花

from turtle import *
color('red','pink')
begin_fill()
while True:
    forward(200)
    left(150)
    if(abs(pos()))<1:
        break
end_fill()
done()

 

五个五角星

from turtle import*
setup(600,400,0,0)
color('yellow')
bgcolor('red')
fillcolor('yellow')
begin_fill()
up()
goto(-250,75)
for i in range(5):
forward(100)
right(144)
down()
end_fill()
def cnygoto(x,y):
up()
goto(x,y)
down()
begin_fill()
for i in range(5):
forward(50)
right(144)
end_fill()


cnygoto(-90,150)
cnygoto(-100,50)
cnygoto(-150,-30)
cnygoto(-250,-75)

 

 

 

posted on 2017-09-12 09:58  004陈楠芸  阅读(140)  评论(0编辑  收藏  举报