Python绘制一条彩色蟒蛇(两种常规的方法)

Python绘制一条彩色蟒蛇,每个小段,画笔的颜色发生变化
方法一:
import turtle
a=[‘purple’,‘red’,‘yellow’,‘pink’]
turtle.setup(650, 350, 200, 200)
turtle.penup()
turtle.fd(-250)
turtle.pendown()
turtle.pensize(25)
turtle.seth(-40)
for i in range(4):
turtle.pencolor(a[i])
turtle.circle(40, 80)
turtle.circle(-40, 80)
turtle.pencolor(“green”)
turtle.circle(40, 80/2)
turtle.fd(40)
turtle.circle(16, 180)
turtle.fd(40 * 2/3)

方法二:
from turtle import *
setup(650, 350, 200, 200)
penup()
fd(-250)
pendown()
pensize(25)
a=[‘purple’,‘red’,‘yellow’,‘pink’]
seth(-40)
for i in range(4):
pencolor(a[i])
circle(40, 80)
circle(-40, 80)
pencolor(“green”)
circle(40, 80/2)
fd(40)
circle(16, 180)
fd(40 * 2/3)
Python绘制一条彩色蟒蛇(两种常规的方法)_第1张图片

你可能感兴趣的:(Python)