python 雪花



#KochDrawV2.py
import turtle
def koch(size, n):
	if n == 0:
		turtle.speed(0)
		turtle.fd(size)
		turtle.fillcolor("yellow")
	else:
		for angle in [0, 60, -120, 60]:
			turtle.left(angle)
			koch(size/3, n-1)
def main():
	turtle.setup(600,600)
	turtle.speed(0)
	# turtle.Turtle().screen.delay(0)
	turtle.penup()
	# turtle.penup()
	turtle.goto(-200, 100)
	turtle.pendown()
	turtle.pensize(2)
level = 3 # 3阶科赫雪花,阶数
koch(100, level)
turtle.right(120)
koch(100, level)
turtle.right(120)
koch(100, level)
turtle.fillcolor("yellow")
turtle.hideturtle()
turtle.done()
main()

全部评论

相关推荐

牛客33727151号:不是哥们我以为驾照是段子呢
点赞 评论 收藏
分享
运营3年修炼中接简历辅导:你的科研项目经历里,只写了你的动作,没有写你的思考和成果,不要只写使用什么进行了什么,这等于罗列你的任务,简历是为了突出你的优秀,你在什么样的任务背景下,克服了什么样的困难,针对性地做了哪些事情,最后达成了什么成果(用数据体现你的成果和效率)
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务