while循环与 for循环,函数定义与调用

import turtle
turtle.bgcolor('light blue')
turtle.color('pink')
turtle.fillcolor('pink')
turtle.begin_fill()


while True:
    turtle.forward(150)
    turtle.right(260)
    if abs(turtle.pos())<1:
        break
turtle.end_fill()

turtle.done()

import turtle

turtle.setup(600,400,0,0)
turtle.bgcolor('red')
turtle.color('yellow')
turtle.fillcolor('yellow')

def mygoto(x,y):
    turtle.penup()
    turtle.goto(x,y)
    turtle.pendown()


def draw5jx(f):
    turtle.begin_fill()
    for i in range(5):
         turtle.forward(f)
         turtle.right(144)
    turtle.end_fill()

mygoto(-250,100)
draw5jx(100)

mygoto(-100,125)
draw5jx(50)

mygoto(-70,50)
draw5jx(50)
turtle.end_fill()

mygoto(-90,-40)
draw5jx(50)

mygoto(-140,-90)
draw5jx(50)


turtle.done()

posted @ 2018-05-14 16:51  FBYi  阅读(470)  评论(0编辑  收藏  举报