函数定义与使用

Posted xiefei33--

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了函数定义与使用相关的知识,希望对你有一定的参考价值。

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()
def myfor(a,b):
    turtle.begin_fill()
    for i in range(5):
        turtle.forward(a)
        turtle.right(b)
    turtle.end_fill()



mygoto(-250,100)
myfor(100,144)

mygoto(-100,155)
myfor(25,144)


mygoto(-55,125)
myfor(25,144)

mygoto(-55,65)
myfor(25,144)

mygoto(-100,25)
myfor(25,144)



turtle.done()

技术分享图片

 

以上是关于函数定义与使用的主要内容,如果未能解决你的问题,请参考以下文章