一段turtle程序
import random
A=0
B=0
C=0
D=0
E=0
F=0
gs=random.randint(4,6)
aa=[]
if gs==4:
for i in range(0,15):
D+=1
if D==2:
D=0
C=C+1
if C==2:
C=0
B=B+1
if B==2:
B=0
A=A+1
a=[A,B,C,D]
aa.append(a)
if gs==5:
for i in range(0,31):
E+=1
if E==2:
E=0
D=D+1
if D==2:
D=0
C=C+1
if C==2:
C=0
B=B+1
if B==2:
B=0
A=A+1
a=[A,B,C,D,E]
aa.append(a)
if gs==6:
for i in range(0,63):
F+=1
if F==2:
F=0
E=E+1
if E==2:
E=0
D=D+1
if D==2:
D=0
C=C+1
if C==2:
C=0
B=B+1
if B==2:
B=0
A=A+1
a=[A,B,C,D,E]
aa.append(a)
s=2**gs-1
import turtle
turtle.setup(800,600)
turtle.tracer(0)
turtle.speed(1000)
turtle.left(90)
for n in range (50):
x=random.randint(-400,400)
y=random.randint(-300,300)
bb=random.randint(30,60)
b=bb
i=0
if x>0:
d=22.5
else:
d=-22.5
for i in range(s):
c=0
turtle.penup()
turtle.goto(x,y)
turtle.pendown()
j=0
b=bb
for j in range(gs-1):
if aa[i][j]==1:
turtle.left(5-d)
turtle.forward(b)
b=b-6
c=c+5-d
else:
turtle.right(5+d)
turtle.forward(b)
b=b-6
c=c-5-d
turtle.right(c)