import turtle
t=turtle.Pen()
color = ['red','yellow','blue','green']
for x in range(100):
t.pencolor(color[x%4])
t.forward(x)
t.left(90)
案例9:用for画螺旋线
import turtle
t=turtle.Pen()
color = ['red','yellow','blue','green']
for x in range(100):
t.pencolor(color[x%4])
t.forward(x)
t.left(91)
案例10:for画五角星
import turtle
t=turtle.Pen()
t.begin_fill()
t.fillcolor('red')
for x in range(5):
t.forward(100)
t.right(144)
t.end_fill()
turtle.done()
案例11:max画图
import turtle
t=turtle.Pen()
for i in range(0,100):
t.write("max",font=("Arial",int((i+4)/4),"bold"))
t.penup()
t.forward(i*4)
t.pendown()
t.left(92)
案例12:max不同颜色
import turtle
t=turtle.Pen()
colors=['red','yellow','blue','green','purple']
for i in range(0,50):
t.write("max",font=("Arial",int(i+5/5),"bold"))
t.pencolor(colors[i%5])
t.penup()
t.forward(i*8)
t.pendown()
t.left(74)