Day041.画蟒蛇-用函数来封装
运行结果
代码如下
'''
画蟒蛇,使用函数将蟒蛇功能封装
@Ref 2017.Python语言程序设计基础.第2版.嵩天, p55
@Version: v0.1, Python 3.9.5, Notus(hehe_xiao@qq.com), 2021.06.16
@Updated: 2021.06.16
'''
from turtle import *
def drawSnake(radius, angle, len):
seth(-40)
for i in range(len):
circle(radius, angle)
circle(-radius, angle)
circle(radius, angle / 2)
fd(40)
circle(16, 180)
fd(40 * 2 /3)
setup(650, 350, 200, 200)
penup()
fd(-250)
pendown()
pensize(25)
pencolor("purple")
drawSnake(40, 80, 4)
done()