函数定义与使用

import turtle
#画一个五角星
turtle. setup(600,400,0,0)

turtle.bgcolor('red')
turtle.pencolor('yellow')
turtle.fillcolor('yellow')

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

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

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

mygoto(-250,100)
turtle.begin_fill()
for i in range(5):
    turtle.forward(50)
    turtle.right(144)
    turtle.end_fill()

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

mygoto(-250,100)
turtle.begin_fill()
for i in range(5):
    turtle.forward(50)
    turtle.right(144)
    turtle.end_fill()

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

mygoto(-250,100)
turtle.begin_fill()
for i in range(5):
    turtle.forward(50)
    turtle.right(144)
    turtle.end_fill()

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

mygoto(-250,100)
turtle.begin_fill()
for i in range(5):
    turtle.forward(50)
    turtle.right(144)
    turtle.end_fill()

hideturtle()
turtle.done()

posted @ 2018-05-16 21:20  Milliezhu  阅读(133)  评论(0编辑  收藏  举报