# 实验八

 1 from turtle import *
2 def square(size=50,rgb='yellow'):
3     pencolor(rgb)
4     for i in range(4):
5         fd(size)
6         left(90)
7 setup(800,600)
8 speed(0)
9 n=10
10 for i in range(n):
11     square(80)
12     left(360/n)
13 hideturtle()
14 done()

 1 from turtle import *
2 setup(800,600)
3 speed(0)
4 pencolor('pink')
5 n=10
6 for i in range(n):
7     for j in range(2):
8         circle(80,90)
9         left(90)
10     right(360/n)
11
12 hideturtle()
13 done()

 1 from turtle import *
2 setup(800,600)
3 speed(0)
4 pencolor('white')
5 bgcolor('black')
6
7 angle=0
8 size=2
9
10 n=10
11 for i in range(n):
12     for j in range(4):
13         fd(size)
14         angle+=71
15         seth(angle)
16         size+=5
17
18
19 hideturtle()
20 done()

 1 from turtle import *
2 from random import random
3 setup(800,600)
4 speed(0)
5 def rect(w,h,fc):
6     fillcolor(fc)
7     for i in range(1,5):
8         if i%2==1:
9             d=w
10         else:
11             d=h
12         fd(d)
13         left(90)
14 def moveto(x,y):
15     penup()
16     goto(x,y)
17     pendown()
18 for i in range(10):
19     moveto(-20*i,0)
20     rgb=tuple(random()for i in range(3))
21     begin_fill()
22     rect(20,50,rgb)
23     end_fill()
24 for i in range(10):
25     moveto(20*i,0)
26     rgb=tuple(random()for i in range(3))
27     begin_fill()
28     rect(20,50,rgb)
29     end_fill()
30 hideturtle()
31 done()

posted on 2022-06-14 10:19  lsw()  阅读(8)  评论(0编辑  收藏  举报