循环练习

五角星

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

 

同心圆

import turtle

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

 

 

打靶的圆

import turtle

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

 

太阳花

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

   

5个五角星 函数定义

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

 

posted @ 2017-09-12 10:37  003刘淑千  阅读(117)  评论(0编辑  收藏  举报