#Python 蟒蛇实例
"""
import turtle #引入turtle绘制图像外部库
def drawSnake(rad, angle, len, neckrad):#def 用于定义函数
for i in range(len):
turtle.circle(rad, angle)#rad描述圆形轨迹半径的位置,angle弧度值
turtle.circle(-rad, angle)
turtle.circle(rad, angle/2)
turtle.fd(rad)#距离
turtle.circle(neckrad+1,180)
turtle.fd(rad*2/3)
def main():
turtle.setup(1300, 800, 0, 0)#启动窗口函数(宽度,高度,及左上角的坐标位置X,Y(向右,向下))
pythonsize = 30
turtle.pensize(pythonsize)#运行宽度
turtle.pencolor("blue")#运行颜色 3B9909
turtle.seth(-40)#启动时运行的方向,角度值,逆时针增加度数
drawSnake(40, 80, 5, pythonsize/2)
main()
"""
#彩色蟒蛇
import turtle
def drawSnake(rad,angle,len,neckrad):
mycolor=["black","red","red","blue","yellow"]
yocolor=["yellow","green","yellow","red","red"]
for i in range(len):
turtle.pencolor(mycolor[i])
turtle.circle(rad,angle)
turtle.pencolor(yocolor[i])
turtle.circle(-rad,angle)
turtle.pencolor("green")
turtle.circle(rad,angle/2)
turtle.pencolor("yellow")
turtle.fd(rad)
turtle.pencolor("red")
turtle.circle(neckrad+1,180)
turtle.pencolor("green")
turtle.fd(rad*2/3)
def main():
turtle.setup(1300,800,0,0)
pythonsize=30
turtle.pensize(pythonsize)
turtle.seth(-40)
drawSnake(40,80,5,pythonsize/2)
main()